Failed to initialize NVML: Driver/library version mismatch 에러 해결
원인
커널 모듈에 올라간 드라이버 버전과 클라이언트에서 사용하는 라이브러리 버전이 다른 경우 발생함.
문제 확인
dmesg 를 사용해서 커널 로그를 확인합니다.[1] 로그를 보면 버전이 일치하지 않는다는 메세지를 확인할 수 있습니다.
$ dmesg|grep -i nvrm
[1539409.084595] NVRM: API mismatch: the client has the version 515.76, but
NVRM: this kernel module has the version 515.48.07. Please
NVRM: make sure that this kernel module and all NVIDIA driver
NVRM: components have the same version.
apt or apt-get 으로 드라이버를 설치한 경우 기존 드라이버가 남아 있는등의 이유로 문제가 발생할 수 있습니다.
modinfo nvidia 명령어를 통해서 470.141.03 버전이 설치되어 있는 것을 확인할 수 있고,
root@root:~$ modinfo nvidia
filename: /lib/modules/5.4.0-131-generic/updates/dkms/nvidia.ko
firmware: nvidia/470.141.03/gsp.bin
alias: char-major-195-*
version: 470.141.03
supported: external
license: NVIDIA
~~ 내용이 많지만 가독성을 위해 이하 삭제함 ~~
위 버전이 /usr/lib/x86_64-linux-gnu의 파일들의 라이브러리 버전과 일치해야 합니다.
root@root:/usr/lib/x86_64-linux-gnu$ ls -al | grep libnvidia
lrwxrwxrwx 1 root root 24 7월 29 18:21 libnvidia-allocator.so -> libnvidia-allocator.so.1
lrwxrwxrwx 1 root root 33 7월 29 18:21 libnvidia-allocator.so.1 -> libnvidia-allocator.so.470.141.03
-rw-r--r-- 1 root root 98688 7월 1 03:33 libnvidia-allocator.so.470.141.03
-rw-r--r-- 1 root root 762400 7월 1 03:34 libnvidia-cbl.so.470.141.03
~~ 파일들이 많지만 가독성을 위해 이하 삭제함 ~~
버전이 매치되는 파일이 있더라도, 드라이버가 다른 버전의 파일을 바라보고 있는 경우도 있는것 같습니다.
문제 해결
시스템에 설치된 nvidia driver, library 를 모두 제거하고, 사용하려는 nvidia driver version 을 설치하면 됩니다.
1. Disable GUI on boot
$ sudo systemctl set-default multi-user
2. Logout from GUI session
$ gnome-session-quit
3. Ubuntu desktop 삭제
$ sudo apt purge ubuntu-desktop -y && sudo apt autoremove -y && sudo apt autoclean
4. nvidia 관련 드라이버, 라이브러리 삭제
$ sudo apt remove nvidia-* && sudo apt autoremove
5. nvidia gpu driver 재설치
** apt or apt-get 명령어를 사용해서 설치하지 않는다.
** https://www.nvidia.com/download/index.aspx 에서 사용하려는 드라이버를 다운로드 받아 설치합니다.
** 설치시 참조 [3]
6. Nvidia container Runtime 설치
https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html
참조
[1] https://eehoeskrap.tistory.com/259
[Linux] dmesg 명령어
dmesg 명령어 dmesg 명령어는 시스템 부팅 메세지를 확인하는 명령어이다. 또한 커널에서 출력되는 메세지를 일정 수준 기록하는 버퍼 역할을 수행하며, 커널 부팅 중에 에러가 났다면 어느 단계에
eehoeskrap.tistory.com
How to fix "NVRM: API mismatch" between client version and kernel module version when installing Nvidia drivers for a GTX 560 Ti
I have installed nvidia-driver-390 after adding a GTX 560 Ti on an Intel Core i5 12600K PC running Kubuntu 20.04 LTS. After rebooting I get the following error: $ dmesg|grep -i nvrm -A3 [ 113.6470...
stackoverflow.com
[3] https://docs.nvidia.com/datacenter/tesla/tesla-installation-notes/index.html
NVIDIA Driver Installation Quickstart Guide :: NVIDIA Tesla Documentation
Before installing the NVIDIA driver on Linux, some pre-installation steps are recommended to: Verify the system has a CUDA-capable GPU Verify the system is running a supported version of Linux Verify the system has build tools such as make, gcc installed V
docs.nvidia.com