配置记录ubuntu

1、conda换源

vim ~/.condarc 
channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
  - default
ssl_verify: true

2、pip换源

pip install django -i https://pypi.tuna.tsinghua.edu.cn/simple


vim ~/.pip/pip.conf

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=pypi.tuna.tsinghua.edu.cn

3、安装cuda10.0+cudnn7.4.1

python+tensorflow+cuda+cudnn对应关系  https://tensorflow.google.cn/install/source

(1)安装cuda
参考https://blog.csdn.net/c19961227/article/details/103381462

sudo apt-get install freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev 


sudo chmod a+x cuda_xx_linux.run
sudo ./cuda_xx_linux.run

然后,添加环境变量
vim ~/.bashrc
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-10.0/lib64
export PATH=$PATH:/usr/local/cuda-10.0/bin
export CUDA_HOME=$CUDA_HOME:/usr/local/cuda-10.0

保存后退出
终端输入 nvcc -V ,出现

dg@dg-pc:~$ nvcc -V
nvcc: NVIDIA ® Cuda compiler driver
Copyright © 2005-2018 NVIDIA Corporation
Built on Sat_Aug_25_21:08:01_CDT_2018
Cuda compilation tools, release 10.0, V10.0.130

再去 /home/下中找文件夹 NVIDIA_CUDA-10.0_Samples/
cd /home/xxx/NVIDIA_CUDA-10.0_Samples
make

然后就开始编译,等一阵子,出现
Finished building CUDA samples
就好了


gcc版本过高
sudo apt-get install g++-7
sudo apt-get install gcc-7

sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 10 
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 10


卸载
sudo /usr/local/cuda-10.0/bin/uninstall_cuda_10.0.pl




(2)安装cudnn

参考:https://blog.csdn.net/u010397980/article/details/86512742

https://developer.nvidia.com/rdp/cudnn-archive#a-collapse51b

cp cudnn-10.0-linux-x64-v7.5.0.56.solitairetheme8 cudnn-7.tgz
tar -xvf cudnn-7.tgz

解压压缩包:

tar -xvf cudnn-9.0-linux-x64-v7.4.1.5.tgz

显示以下信息:

cuda/include/cudnn.h
cuda/NVIDIA_SLA_cuDNN_Support.txt
cuda/lib64/libcudnn.so
cuda/lib64/libcudnn.so.7
cuda/lib64/libcudnn.so.7.4.1
cuda/lib64/libcudnn_static.a

 

继续执行以下指令:

sudo cp cuda/include/cudnn.h /usr/local/cuda/include/

sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/

sudo chmod a+r /usr/local/cuda/include/cudnn.h

sudo chmod a+r /usr/local/cuda/lib64/libcudnn*

至此,cuda9和cudnn7安装完成。

(3)验证
cuda版本
cat /usr/local/cuda/version.txt

cudnn版本
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
 

4、安装docker使用gpu

参考网址 https://blog.csdn.net/weixin_40965132/article/details/118511876

安装nvidia驱动
sh NVIDIA-Linux-x86_64-460.39.run

apt install gcc
apt install make

安装docker
apt install docker.io

设置开机自动启动
systemctl start docker
systemctl enable docker

docker -V

安装toolkit
配置docker19使用gpu
# Add the package repositories
$ distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
$ curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
$ curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list

$ sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit
$ sudo systemctl restart docker

检测docker调用宿主机gpu
docker run --gpus=all nvidia/cuda:9.0-base nvidia-smi


5、gcc编译器

sudo apt-get install -y gcc-5
sudo apt-get install -y g++ -5

gcc --version
g++ --version

切换gcc版本
cd /usr/bin
sudo rm gcc
sudo ln -s gcc-7 gcc
sudo rm g++
sudo ln -s g++-7 g++

6、

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值