ubuntu 安装NVIDIA驱动 cuda NVIDIA-docker

1.安装NVIDIA驱动

sudo add-apt-repository ppa:graphics-drivers/ppaaudo apt-get update
sudo apt-get install nvidia-390

检测驱动安装状态:

nvidia-smi

如果出现如下类似相关输出,表示成功。

 

2.安装cuda9.0

2.1安装

https://developer.nvidia.com/cuda-90-download-archive?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1604&target_type=runfilelocal

我们这里使用runfile安装,方便快捷。

 

下载完成后,输入sudo sh cuda_9.0.176_384.81_linux.run安装,然后根据提示一步一步安装,注意不要安装它自带的显卡驱动。

2.2设置环境变量

 sudo vim /etc/profile

在文件末尾添加以下两行。

64位系统:

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

32位系统:

export PATH=/usr/local/cuda-9.0/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib:$LD_LIBRARY_PATH

2.3验证

a.验证cuda toolkit:

nvcc -V

b.编译sample

cd /home/user_name/NVIDIA_CUDA-9.0_Samples/1_Utilities/deviceQuery
make
./deciveQuery

最后一行为Result=PASS 即为通过

3安装NVIDIA-docker

Ubuntu系统安装:

# If you have nvidia-docker 1.0 installed: we need to remove it and all existing GPU containers
docker volume ls -q -f driver=nvidia-docker | xargs -r -I{} -n1 docker ps -q -a -f volume={} | xargs -r docker rm -f
sudo apt-get purge -y nvidia-docker

# Add the package repositories
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | \
  sudo apt-key add -
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
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

# Install nvidia-docker2 and reload the Docker daemon configuration
sudo apt-get install -y nvidia-docker2
sudo pkill -SIGHUP dockerd

# Test nvidia-smi with the latest official CUDA image
docker run --runtime=nvidia --rm nvidia/cuda nvidia-smi

 

 

 

参考资料: cuda+NVIDIA驱动安装: https://blog.csdn.net/jonms/article/details/79318566

                   NVIDIA-docker安装:     https://blog.csdn.net/chxw098/article/details/79741586

你可能感兴趣的:(ubuntu 安装NVIDIA驱动 cuda NVIDIA-docker)