linux 服务器无 sudo 权限非 root 用户安装特定版本 cuda

avatar
作者
筋斗云
阅读量:0

1. 下载 cuda toolkit 

下载想要版本的 cuda toolkit

CUDA Toolkit 11.8 Downloads | NVIDIA Developer

  [xxx@localhost ~]$ hostnamectl    Static hostname: localhost.localdomain          Icon name: computer-server            Chassis: server         Machine ID: b4258bf9bef54798b03e8e3a13756124            Boot ID: df28bae14b0a4398a6ddb7fa3ee20c90   Operating System: CentOS Linux 8 (Core)        CPE OS Name: cpe:/o:centos:centos:8             Kernel: Linux 4.18.0-193.28.1.el8_2.x86_64       Architecture: x86-64 

wget https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_520.61.05_linux.run sudo sh cuda_11.8.0_520.61.05_linux.run

2 无sudo 权限安装CUDA

对于无 sudo 权限 或者 非 root 用户,在安装cuda的时候,将cuda toolkit的安装路径设置为自己有权限的目录就行,比如 /home/zhaozb/cuda-10.0,之后将后续步骤中对应cuda toolkit的安装路径都进行更改就行了 。

要实现上一步,首先需要进入tmp查看是否存在cuda-installer.log文件,如果存在,你是没法办装的,得让这个文件的所有者或者具有sudo 权限的管理员将其删除,同样,你安装完后也会生成这个文件,记得使用 rm -rf cuda-installer.log删掉!!

cd /tmp ls -l cuda-installer.log    #查看文件信息

 删除

sudo 登录

sudo rm -rf cuda-installer.log

再次查看

ls -l cuda-installer.log    #查看文件信息

如果报no such file or directory表示不存在该文件,按照一下步骤安装CUDA toolkit

[@localhost software]$ sh cuda_11.8.0_520.61.05_linux.run Log file not open. cuda_11.8.0_520.61.05_linux.run: line 524: 2195323 Segmentation fault      (core dumped) ./cuda-installer ┌─┐ │  End User License Agreement                                                  │ │  -                                                                           │ │                                                                              │ │  NVIDIA Software License Agreement and CUDA Supplement to                    │ │  Software License Agreement. Last updated: October 8, 2021                   │ │                                                                              │ │  The CUDA Toolkit End User License Agreement applies to the                  │ │  NVIDIA CUDA Toolkit, the NVIDIA CUDA Samples, the NVIDIA                    │ │  Display Driver, NVIDIA Nsight tools (Visual Studio Edition),                │ │  and the associated documentation on CUDA APIs, programming                  │ │  model and development tools. If you do not agree with the                   │ │  terms and conditions of the license agreement, then do not                  │    download or use the software.     Last updated: October 8, 2021.      Preface    -   ─   Do you accept the above EULA? (accept/decline/quit): 

键入accept

除了cuda toolkit其他全部取消,然后进入options

 然后进入options,把X全部去掉

进入change path更改路径,因为没有root权限,没办法放入默认路径,因此更改为自己的路径即可,我更改为/home1/username/cuda-11.8(需要提前自己创建 mkdir /home1/username/cuda-11.8)

 

 

回到options界面,修改library install path,

 在刚刚的路径后面新建一个mylib文件夹

回到主界面,选择install开始安装(需要等待一会),

安装好后界面如下

# <<< conda initialize <<<   export LD_LIBRARY_PATH=/home/xxx/cuda-11.3/lib64:${LD_LIBRARY_PATH} export CUDA_INSTALL_DIR=/home/xxx/cuda-11.3   export CUDA_HOME=/home/xxx/cuda-11.3 export CUDA_PATH=/home/xxx/cuda-11.3 export PATH=${CUDA_HOME}/bin:$PATH

按 i 进入insert 模式,粘贴后按 Esc,再输入 :wq 进行保存并退出

执行下列命令让更改立即生效

source ~/.bashrc

[xxx@localhost ~]$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Sun_Mar_21_19:15:46_PDT_2021
Cuda compilation tools, release 11.3, V11.3.58
Build cuda_11.3.r11.3/compiler.29745058_0

大功告成! 

[xxx@localhost ~]$ sh cuda_11.3.0_465.19.01_linux.run =========== = Summary = ===========  Driver:   Not Selected Toolkit:  Installed in /home/xxx/cuda-11.3/ Samples:  Not Selected  Please make sure that  -   PATH includes /home/xxx/cuda-11.3/bin  -   LD_LIBRARY_PATH includes /home/xxx/cuda-11.3/lib64, or, add /home/xxx/cuda-11.3/lib64 to /etc/ld.so.conf and run ldconfig as root  To uninstall the CUDA Toolkit, run cuda-uninstaller in /home/xxx/cuda-11.3/bin ***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least 465.00 is required for CUDA 11.3 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-installer.log [xxx@localhost ~]$ vim ~/.bashrc [xxx@localhost ~]$ source ~/.bashrc [xxx@localhost ~]$ nvcc -V nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2021 NVIDIA Corporation Built on Sun_Mar_21_19:15:46_PDT_2021 Cuda compilation tools, release 11.3, V11.3.58 Build cuda_11.3.r11.3/compiler.29745058_0  

3 安装并管理多版本CUDA 

按照上述步骤下载安装,最后将.bashrc中CUDA 的路径更改一下即可。

广告一刻

为您即时展示最新活动产品广告消息,让您随时掌握产品活动新动态!