sudo sh cuda_10.1.243_418.87.00_linux.run =========== = Summary = ===========
Driver: Not Selected Toolkit: Installed in /usr/local/cuda-10.1/ Samples: Installed in /home/lintong/, but missing recommended libraries
Please make sure that - PATH includes /usr/local/cuda-10.1/bin - LD_LIBRARY_PATH includes /usr/local/cuda-10.1/lib64, or, add /usr/local/cuda-10.1/lib64 to /etc/ld.so.conf and run ldconfig as root
To uninstall the CUDA Toolkit, run cuda-uninstaller in /usr/local/cuda-10.1/bin
Please see CUDA_Installation_Guide_Linux.pdf in /usr/local/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 /var/log/cuda-installer.log
在~/.bashrc或者/etc/profile中添加,然后source
1 2 3 4
# cuda export PATH=/usr/local/cuda-10.1/bin${PATH:+:${PATH}} export LD_LIBRARY_PATH=/usr/local/cuda-10.1/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
验证是否安装成功
1 2 3 4 5 6
lintong@master:~/下载$ nvcc -V nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2019 NVIDIA Corporation Built on Sun_Jul_28_19:07:16_PDT_2019 Cuda compilation tools, release 10.1, V10.1.243
1. There appears to already be a driver installed on your system (version: 515.76). As part of installing this driver (version: 515.76), the existing driver will be uninstalled. Are you sure you want to continue? Continue installation Abort installation (选择 Coninue,如果是重装的话) 2. The distribution-provided pre-install script failed! Are you sure you want to continue? Continue installation Abort installation (选择 Cotinue) 3. Would you like to register the kernel module sources with DKMS? This will allow DKMS to automatically build a new module, if you install a different kernel later. Yes No (这里选 No) 4. Install NVIDIA's 32-bit compatibility libraries? Yes No (这里选 No) 5. Installation of the kernel module for the NVIDIA Accelerated Graphics Driver for Linux-x86_64 (version 515.76) is now complete. OK 6.Would you like to run the nvidia-xconfigutility to automatically update your x configuration so that the NVIDIA x driver will be used when you restart x? Any pre-existing x confile will be backed up. Yes No (这里选 Yes)
nvidia-smi Tue Oct 25 23:51:22 2022 +-----------------------------------------------------------------------------+ | NVIDIA-SMI 515.76 Driver Version: 515.76 CUDA Version: 11.7 | |-------------------------------+----------------------+----------------------+ | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | | | | MIG M. | |===============================+======================+======================| | 0 NVIDIA GeForce ... Off | 00000000:01:00.0 On | N/A | | 40% 36C P0 N/A / 100W | 371MiB / 4096MiB | 0% Default | | | | N/A | +-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+ | Processes: | | GPU GI CI PID Type Process name GPU Memory | | ID ID Usage | |=============================================================================| | 0 N/A N/A 1106 G /usr/lib/xorg/Xorg 369MiB | +-----------------------------------------------------------------------------+
python3.6 Python 3.6.13 (default, Feb 20 2021, 21:42:50) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from torch.backends import cudnn >>> print(cudnn.is_available()) True
python3.6 Python 3.6.13 (default, Feb 20 2021, 21:42:50) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import torch >>> print(torch.cuda.is_available()) /home/lintong/.local/lib/python3.6/site-packages/torch/cuda/__init__.py:80: UserWarning: CUDA initialization: The NVIDIA driver on your system is too old (found version 10010). Please update your GPU driver by downloading and installing a new version from the URL: http://www.nvidia.com/Download/index.aspx Alternatively, go to: https://pytorch.org to install a PyTorch version that has been compiled with your version of the CUDA driver. (Triggered internally at ../c10/cuda/CUDAFunctions.cpp:112.) return torch._C._cuda_getDeviceCount() > 0 False
安装515.76版本后
1 2 3 4 5 6 7 8 9 10 11 12
python3.6 Python 3.6.13 (default, Feb 20 2021, 21:42:50) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import torch >>> print(torch.cuda.is_available()) True >>> print(torch.cuda.device_count()) 1 >>> print(torch.cuda.get_device_name(0)) 'NVIDIA GeForce GTX 1050 Ti'