CentOS 7下NVIDIA驱动已安装但nvidia-smi无法调用问题求助
nvidia-smi Not Found and CUDA Installation on CentOS 7 Hey there, let's work through your issues one by one:
a) Fixing the nvidia-smi: command not found error
Since you've confirmed the NVIDIA kernel module is installed (via cat /proc/driver/nvidia/version), the most likely issue is that the directory containing nvidia-smi isn't in your system's PATH environment variable. Here's how to fix it:
Locate the
nvidia-smiexecutable
Run this command to find where the binary is stored (it might take a minute):find / -name nvidia-smi 2>/dev/nullCommon locations on CentOS 7 are
/usr/bin/nvidia-smior/usr/local/nvidia/bin/nvidia-smi.Add the directory to your
PATH- Temporary fix (applies only to your current session):
If the path was/usr/local/nvidia/bin, run:
Test it by runningexport PATH=$PATH:/usr/local/nvidia/binnvidia-smiright after. - Permanent fix (persists across reboots):
Edit your bash profile to add the path permanently:
Then reload the profile:echo 'export PATH=$PATH:/usr/local/nvidia/bin' >> ~/.bashrc
Nowsource ~/.bashrcnvidia-smishould work every time you log in.
- Temporary fix (applies only to your current session):
If the find command doesn't return any results, it might mean the full NVIDIA driver package wasn't installed (only the kernel module). In that case, you'll need to reinstall the driver package that includes user-space tools like nvidia-smi.
b) Installing CUDA on CentOS 7
First, note the driver-CUDA compatibility: Your NVIDIA driver version is 390.30, which supports CUDA 9.0 (minimum required driver for CUDA 9.0 is 384.81) or older versions. CUDA 9.1 and newer require a driver version ≥390.46, which is higher than your current 390.30, so stick with CUDA 9.0 for compatibility.
Follow these steps:
Install required dependencies
Ensure you have the necessary development tools and kernel headers:sudo yum install -y gcc gcc-c++ kernel-devel kernel-headersYour existing GCC 4.8.5 is compatible with CUDA 9.0, so no need to upgrade it.
Run the CUDA installer
Grab the CentOS 7 runfile installer (avoid the RPM version if you want to skip driver installation, since you already have a working driver). Make it executable and run with sudo:chmod +x cuda_9.0.176_384.81_linux.run sudo sh cuda_9.0.176_384.81_linux.runWhen prompted:
- Do you accept the EULA? Type
accept - Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 384.81? Select
no(you already have a newer driver installed) - Install the CUDA 9.0 Toolkit? Select
yes - Install the CUDA 9.0 Samples? Select
yes(optional but useful for testing) - Choose your preferred installation paths (defaults are usually fine)
- Do you accept the EULA? Type
Configure CUDA environment variables
Add CUDA's binary and library paths to your profile:echo 'export PATH=$PATH:/usr/local/cuda-9.0/bin' >> ~/.bashrc echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-9.0/lib64' >> ~/.bashrc source ~/.bashrcVerify the installation
Check the CUDA compiler version:nvcc -VYou can also run the device query sample to confirm CUDA recognizes your GPU:
cd /usr/local/cuda-9.0/samples/1_Utilities/deviceQuery make ./deviceQueryIf it outputs a
Result = PASS, your CUDA installation is working correctly.
内容的提问来源于stack exchange,提问作者AruniRC

