每次装环境,都得百度,索性自己写个参考吧。

配置深度学习环境三部曲:

1.Nvidia驱动安装(推荐高一些的版本,但别最高版本,难度:难搞)

2.Cuda、CuDNN安装(按需求来)

3.Anaconda

 

本文主要介绍Cuda和CuDNN的安装(会涉及多个Cuda安装)

装Cuda总路线:下载Cuda--->安装--->配置环境变量

装多个Cuda:安装类似总路线,仅仅环境变量那里需要修改

1.下载Cuda

一般下载run格式,自己根据需求安装Cuda

https://www.baidu.com/link?url=r8puC4uyB3o3Gx5GByxVNhWCx4bg3-7Zb_FjJPaUTkZDf1P1NdyUfSMghBIMArwOKu9Hm7U-ygrJFmFIeGw8fs_CVVbtGjWLsrgx-KxGldG&wd=&eqid=d6ab26cb008d57000000000360613545

cuda GPU 分卡以后怎么指定_cuda

2.安装Cuda

sudo sh cuda_10.1.105_418.39_linux.run

开始安装(下面是参考别人的,自己没留):

需要两个地方:1>注意Driver,驱动不装  2>软链接(a symbolic)随便把,其实不影响,很容易改。单个cuda就yes,多个cuda选yes就指向了当前Cuda,选No就没指向,但是选No可能安装失败,这个很容易改,YES就行。

sudo sh cuda_8.0.61_375.26_linux.run #开始安装
 
#..一堆协议说明...
#直接按q退出协议说明.
zerozone@zerozone: accept/decline/quit: accept  #接受协议
 
Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 375.26? 
y)es/(n)o/(q)uit: n  #是否显卡驱动包,由于已经安装显卡驱动,选择n
 
Install the CUDA 8.0 Toolkit?
(y)es/(n)o/(q)uit: y #是否安装工具包,选择y
 
Enter Toolkit Location
[ default is /usr/local/cuda-8.0 ]: #工具包安装地址,默认回车即可
 
Do you want to install a symbolic link at /usr/local/cuda?
(y)es/(n)o/(q)uit: y #添加链接**注意这个连接,如果你之前安装过另一个版本的cuda,除非你确定想要用这个新版本的cuda,否则这里就建议选no,因为指定该链接后会将cuda指向这个新的版本**
 
Install the CUDA 8.0 Samples?
(y)es/(n)o/(q)uit: y #安装样例
 
Enter CUDA Samples Location
 [ default is /root ]:  #样例安装地址默认即可
 
# ***安装信息***
Installing the CUDA Toolkit in /usr/local/cuda-8.0 ...
 
Missing recommended library: libXi.so
Missing recommended library: libXmu.so
#注意,这里出现了Missing recommended library错误,
#是因为博主在第一次安装时,没有添加最开始的那条安装相关依赖的指令,
#之后我添加了依赖后,再次安装,就没有Missing错误了
 
Installing the CUDA Samples in /root ...
Copying samples to /root/NVIDIA_CUDA-8.0_Samples now...
Finished copying samples.
 
===========
= Summary =
===========
Driver:   Not Selected
Toolkit:  Installed in /usr/local/cuda-8.0
Samples:  Installed in /root, but missing recommended libraries
 
Please make sure that
 -   PATH includes /usr/local/cuda-8.0/bin
 -   LD_LIBRARY_PATH includes /usr/local/cuda-8.0/lib64, or, add /usr/local/cuda-8.0/lib64 to /etc/ld.so.conf and run ldconfig as root
 
To uninstall the CUDA Toolkit, run the uninstall script in /usr/local/cuda-8.0/bin
 
Please see CUDA_Installation_Guide_Linux.pdf in /usr/local/cuda-8.0/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 361.00 is required for CUDA 8.0 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_install_6388.log   
# ***安装完成***
————————————————
版权声明:本文为CSDN博主「yinxingtianxia」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:

3.环境变量设置

输入 sudo gedit ~/.bashrc 打开主目录下的 .bashrc文件,在最后面添加如下路径:

说明:我这个没带cuda的版本,因为我后续要指定软链接,如果是单个cuda,可以直接配死,输入 cd /usr/local/,ls,显示出cuda的版本号,用cuda-10.1代替里面的cuda,就这么简单。

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64
export PATH=$PATH:/usr/local/cuda/bin
export CUDA_HOME=$CUDA_HOME:/usr/local/cuda

source ~/.bashrc    # 使环境变量生效

4.多个Cuda的配置(Cuda软链接修改)

cd /usr/local   
ls                                     #会看到有个cuda
stat cuda                    # 会看到当前链接指向哪里
# 目前,我电脑一共3个cuda,下面通过改变软链接改变指向。
cd /usr/local
sudo rm -rf cuda
sudo ln -s /usr/local/cuda-9.0 /usr/local/cuda
stat cuda
# 这样子,会显示指向9.0

cuda GPU 分卡以后怎么指定_CUDA_02