ubuntu22安装nvidia驱动 GeForce RTX 3050 M 以解Cytoscape3.10找不到libOpenCL.so错, Cytoscape3教程

0. 本机环境

uname -a
#Linux v 6.2.0-39-generic #40~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Nov 16 10:53:04 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

cat /etc/issue
#Ubuntu 22.04.3 LTS \n \l


lspci  | grep -i vga
#01:00.0 VGA compatible controller: NVIDIA Corporation GA107M [GeForce RTX 3050 Mobile] (rev a1)

1. 卸载linux自带兼容驱动nouveau


echo 'blacklist nouveau
options nouveau modeset=0' | sudo tee /etc/modprobe.d/blacklist-nouveau.conf

sudo update-initramfs -u
lsmod |grep -i nouveau
#不再有nouveau

2. 重启电脑

重启电脑sudo reboot

重启电脑后,只剩下集成显卡了,而集成显卡不支持双显示器,因此插外接显示器无用。

3*. 官网下载的NVIDA-Linux*.run驱动自己说不建议使用其

下载 目前较新版本是535.146.02


cd ~/Downloads/
sudo chmod +x  ./NVIDIA-Linux-x86_64-535.146.02.run
sudo   ./NVIDIA-Linux-x86_64-535.146.02.run
#他会提示说 由于本系统 ubuntu 有做好的驱动 (指 apt安装  ),不建议用本 .run文件


#   若遇到错误:  You appear to be running an X server; please exit X before installing.  For further details, please see the section INSTALLING THE NVIDIA DRIVER in the README available on the Linux driver download page at www.nvidia.com.
# 增加 --no-x-check 选项
sudo   ./NVIDIA-Linux-x86_64-535.146.02.run   --no-x-check



这里 选择 卸载 .run 的安装内容,并用apt安装


#获得帮助
./NVIDIA-Linux-x86_64-535.146.02.run --help
#获得更多帮助
./NVIDIA-Linux-x86_64-535.146.02.run -A | grep -i uninstall

#卸载  .run 的安装内容
./NVIDIA-Linux-x86_64-535.146.02.run --uninstall

4. apt安装nvidia驱动

支持GeForce RTX 3050 Mobile的驱动版本

  • 第一个支持的驱动版本是510.47.03
  • 目前较新版本是535.146.02

ubuntu22已经有nvidia-driver , 因此不需要添加额外仓库 sudo add-apt-repository ppa:graphics-drivers/ppa ; sudo apt update


sudo apt search --names-only nvidia-driver-53*
#确实能搜索到535版本

sudo apt install nvidia-driver-535

内核模块中有nvidia: lsmod |grep -i nvidia

nvidia_uvm           1765376  0
nvidia_drm             90112  4
nvidia_modeset       1314816  3 nvidia_drm
nvidia              56741888  114 nvidia_uvm,nvidia_modeset
drm_kms_helper        249856  3 drm_display_helper,nvidia_drm,i915
drm                   700416  18 drm_kms_helper,drm_display_helper,nvidia,drm_buddy,nvidia_drm,i915,ttm
video                  73728  3 asus_wmi,i915,nvidia_modeset

命令nvidia-smi的输出:

Mon Dec 25 17:04:21 2023       
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 535.129.03             Driver Version: 535.129.03   CUDA Version: 12.2     |
|-----------------------------------------+----------------------+----------------------+
| 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 RTX 3050 ...    Off | 00000000:01:00.0  On |                  N/A |
| N/A   41C    P8               5W /  60W |     57MiB /  4096MiB |      0%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+
                                                                                         
+---------------------------------------------------------------------------------------+
| Processes:                                                                            |
|  GPU   GI   CI        PID   Type   Process name                            GPU Memory |
|        ID   ID                                                             Usage      |
|=======================================================================================|
|    0   N/A  N/A      1527      G   /usr/lib/xorg/Xorg                           53MiB |
+---------------------------------------------------------------------------------------+

5. ubuntu22下 Cytoscape3.10能正常使用但启动时报错找不到libOpenCL.so

Cytoscape3.10 所用jdk17环境如下:

env | grep -i java
#JAVA_HOME=/jdk17
which javac && which java
#/jdk17/bin/javac
#/jdk17/bin/java
readlink -f `which javac` && readlink -f `which java`
#/app/zulu17.46.19-ca-jdk17.0.9-linux_x64/bin/javac
#/app/zulu17.46.19-ca-jdk17.0.9-linux_x64/bin/java

Cytoscape3.10启动/app/cytoscape-unix-3.10.1/cytoscape.sh后能正常使用,但控制台有如下报错:

karaf@Cytoscape 3.10.1()> [LWJGL] Failed to load a library. Possible solutions:                                                                                       
	a) Install the library or the driver that provides the library.
	b) Ensure that the library is accessible from the system library paths.
[LWJGL] Enable debug mode with -Dorg.lwjgl.util.Debug=true for better diagnostics.
[LWJGL] Enable the SharedLibraryLoader debug mode with -Dorg.lwjgl.util.DebugLoader=true for better diagnostics.
java.lang.UnsatisfiedLinkError: Failed to locate library: libOpenCL.so
	at org.lwjgl.system.Library.loadNative(Library.java:346)
	at org.lwjgl.system.Library.loadNative(Library.java:236)
	at org.lwjgl.system.Library.loadNative(Library.java:217)
	at org.lwjgl.system.Library.loadNative(Library.java:431)
	at org.lwjgl.system.Library.loadNative(Library.java:402)
	at org.lwjgl.opencl.CL.create(CL.java:57)
	at org.lwjgl.opencl.CL.(CL.java:45)
	at org.cytoscape.cycl.internal.CyCL.initialize(CyCL.java:54)
	at org.cytoscape.cycl.internal.CyActivator.lambda$start$0(CyActivator.java:32)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:840)
No devices found

实际上有opencl库, ldconfig -p | grep -i opencl

	libnvidia-opencl.so.1 (libc6,x86-64) => /lib/x86_64-linux-gnu/libnvidia-opencl.so.1
	libnvidia-opencl.so.1 (libc6) => /lib/i386-linux-gnu/libnvidia-opencl.so.1
	libOpenCL.so.1 (libc6,x86-64) => /lib/x86_64-linux-gnu/libOpenCL.so.1

解决办法是 :

  1. 按照以上1到4步骤 安装好 nvidia驱动
  2. 软链接 opencl.so路径 : sudo ln -s /lib/x86_64-linux-gnu/libOpenCL.so.1.0.0 /lib/x86_64-linux-gnu/libOpenCL.so

Cytoscape3.10启动/app/cytoscape-unix-3.10.1/cytoscape.sh后(不再报错)说找到nvidia显卡设备了


karaf.base: /app/cytoscape-unix-3.10.1/framework
JAVA_HOME: /jdk17
             _                                    
   ___ _   _| |_  ___  ___  ___  __ _ _ __   ___  
  / __| | | | __|/ _ \/ __|/ __|/ _` | '_ \ / _ \ 
 | (__| |_| | |_| (_) \__ \ (__| (_| | |_) |  __/ 
  \___|\__, |\__|\___/|___/\___|\__,_| .__/ \___| 
       |___/                         |_|          

Cytoscape 3.10.1

Hit '' for a list of available commands
   and '[cmd] --help' for help on a specific command.
Hit '' or 'osgi:shutdown' to shutdown Cytoscape.

karaf@Cytoscape 3.10.1()> Found 1 platforms           #找到1平台                                                                                                                    
Got 1 platforms
Got 1 devices
Platform: NVIDIA CUDA
Device: OpenCL 3.0 CUDA NVIDIA GeForce RTX 3050 Laptop GPU   #即  找到了 nvidia显卡  
The cl_program [0x7F4B88B75B60] was built successfully
BUILD LOG:
----


-----
Program built
Top device after init = OpenCL 3.0 CUDA NVIDIA GeForce RTX 3050 Laptop GPU
UserAgent = Cytoscape v3.10.1 Java 17.0.9 Linux 6.2.0-39-generic
latestVersion = 3.10.1

6. cytoscape3.10教程

6.1 Cytoscape界面操作

  1. 导入 起点_终点_边字段们,边字段们 是可选的,起点、终点 都是节点,
  2. 导入属性字段, 属性 即 节点的属性
  3. 根据某属性字段的值调整节点颜色,该属性字段是枚举 即 离散, 视频中枚举字段名是type字段
  4. 根据某属性字段的值调整节点尺寸,该属性字段是连续的,视频中的连续字段名是Genenum
  5. 根据某边字段的值调整边的颜色,该字段是边字段,视频中的字段名是PCC

此文内容和上面视频差不多,导入属性字段 较 清楚

6.2 Cytoscape脚本

Cytoscape脚本,
脚本例子New_wrapper_api_sample.ipynb
脚本例子目录 py2cytoscape/examples/

你可能感兴趣的:(python)