报错:$ nvcc -V
The program 'nvcc' is currently not installed. You can install it by typing:
sudo apt install nvidia-cuda-toolkit
提示:不要盲目sudo apt install nvidia-cuda-toolkit 去安装哦。
解决:比如这是一台你和别人共用的机器。先看看机器上别人有没有已经安装过CUDA
$ ls /usr/local/cuda*
如果没有安装,可以参考:linux ubuntu 18.04 卸载cuda10.2 安装cuda 9.0、Ubuntu 18.04搭建tensorflow-gpu环境 等帖子进行安装。
如果已经装了,则编辑~/.bashrc添加配置即可:
# cuda 10.1
export LD_LIBRARY_PATH=/usr/local/cuda/lib
export PATH=$PATH:/usr/local/cuda/bin
# cuda 10.1
使配置生效:
$ source ~/.bashrc
大功告成:
$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Fri_Feb__8_19:08:17_PST_2019
Cuda compilation tools, release 10.1, V10.1.105
感谢:https://blog.csdn.net/qq_34869928/article/details/100544888