1. 程式人生 > 實用技巧 >慢慢安裝——anconda,cuda,cudnn等

慢慢安裝——anconda,cuda,cudnn等

安裝conda 【本身就不需要root許可權】

1.下載anconda https://www.anaconda.com/products/individual
或者直接清華園 https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/ 但是(有時候)出現不穩定:wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2020.02-Linux-x86_64.sh
下載到本地之後,上傳到伺服器,改檔案 chmod 777 ** ,否則出現xftp上傳錯誤
2. sh Anaconda....sh
3.會提示安裝目錄,輸入一個【還沒有建立的安裝目錄】"Anaconda3 will now be installed into this location"

: 如 /4Tdisk/使用者名稱/Anaconda
4.裝完它自己會新增path到~/.bashrc
5. source ~/.bashrc【更新一下使用者配置檔案】,通過conda info --e檢查是否安裝好了

安裝cuda

1.檢視版本顯示卡nvidia-smi,驅動版本是440.44
2.搜“nvidia driver cuda version”,可以看到可以安裝cuda 10.1版本
3.sh cuda***.run
https://blog.csdn.net/hizengbiao/article/details/88625044
4.或者直接使用別人的cuda,寫入到 ~/.profile

換清華源 win/linux下:

https://blog.csdn.net/wujialaoer/article/details/84977796

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge 
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/

conda config --set show_channel_urls yes

PS. 關於找合適的cuda
1.【檢視驅動和cuda匹配版本】nvidia-smi 是440.44版本
2.【檢視核心和cuda匹配版本】gcc -v 是16.04 5.4.0版本
https://docs.nvidia.com/deploy/cuda-compatibility/index.html

https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&ved=2ahUKEwjFt8KR1efpAhVCIqYKHWKyB5IQFjABegQIBBAB&url=http%3A%2F%2Fdocs.nvidia.com%2Fcuda%2Fcuda-installation-guide-linux%2Findex.html&usg=AOvVaw2lfQs0Aks074pu4AYzt75N

【那我就安裝10.1版本的】




安裝cuda和cudnn,自定義目錄

自定義目錄:先建立安裝路徑 /4Tdisk/***/software/cuda/cuda-10.1/
https://blog.csdn.net/hizengbiao/article/details/88625044

【安裝結果】

(base) ***@hp:/4Tdisk/***/download$ sh cuda_10.1.243_418.87.00_linux.run
===========
= Summary =
===========

Driver:   Not Selected
Toolkit:  Installed in /4Tdisk/***/software/cuda/cuda-10.1/
Samples:  Installed in /home/***/

Please make sure that
 -   PATH includes /4Tdisk/***/software/cuda/cuda-10.1/bin
 -   LD_LIBRARY_PATH includes /4Tdisk/***/software/cuda/cuda-10.1/lib64, or, add /4Tdisk/***/software/cuda/cuda-10.1/lib64 to /etc/ld.so.conf and run ldconfig as root

To uninstall the CUDA Toolkit, run cuda-uninstaller in /4Tdisk/***/software/cuda/cuda-10.1/bin

Please see CUDA_Installation_Guide_Linux.pdf in /4Tdisk/***/software/cuda/cuda-10.1/doc/pdf for detailed information on setting up CUDA.
***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least 418.00 is required for CUDA 10.1 functionality to work.
To install the driver using this installer, run the following command, replacing <CudaInstaller> with the name of this run file:
    sudo <CudaInstaller>.run --silent --driver

Logfile is /tmp/cuda-installer.log

【按照Summary配置PATH】

export PATH="/4Tdisk/**/cuda/cuda-10.1/bin:$PATH"
export LD_LIBRARY_PATH="/4Tdisk/**/cuda/cuda-10.1/lib64:$LD_LIBRARY_PATH"

下載解壓cudnn與複製

tar -xzvf cudnn-10.1-linux-x64-v7.6.5.32.tgz -C /4Tdisk/***/software/cuda/cuda-10.1/tem

cp /4Tdisk/***/software/cuda/cuda-10.1/tem/cuda/include/cudnn.h /4Tdisk/***/software/cuda/cuda-10.1/include
cp /4Tdisk/***/software/cuda/cuda-10.1/tem/cuda/lib64/libcudnn* /4Tdisk/***/software/cuda/cuda-10.1/lib64
chmod a+r /4Tdisk/***/software/cuda/cuda-10.1/include/cudnn.h /4Tdisk/***/software/cuda/cuda-10.1/lib64/libcudnn*

檢視版本 nvcc --v

安裝pytorch

1.創環境 conda create --name pytorch
conda install pytorch torchvision cudatoolkit=10.1
或者指定pytorch版本
conda install pytorch=1.5 torchvision cudatoolkit=10.1 -c pytorch