Could not load dynamic library 'libcudart.so.11.0';
我用的conda环境,在
/home/anaconda3/envs/环境名字/lib 文件夹下面能找到libcudart.so.11.0 文件, 但是import 的时候显示
2022-04-25 10:19:13.667333: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory 2022-04-25 10:19:13.667355: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
原因是在conda 该环境下,环境变量没有添加进**/home/anaconda3/envs/环境名字/lib **的路径 解决方案
- 进入该环境目录
/home/username/anaconda3/envs/hls4ml - 创建这些子目录和文件
cd /home/username/anaconda3/envs/hls4ml mkdir -p ./etc/conda/activate.d mkdir -p ./etc/conda/deactivate.d touch ./etc/conda/activate.d/env_vars.sh touch ./etc/conda/deactivate.d/env_vars.sh
3.编辑./etc/conda/activate.d/env_vars.sh , 实现在activate环境的时候激活该环境变量 输入 vim ./etc/conda/activate.d/env_vars.sh 文件里写
#!/bin/sh
export OLD_LD_LIBRARY_PATH=${LD_LIBRARY_PATH}
export LD_LIBRARY_PATH=/home/username/anaconda3/envs/hls4ml/lib:${LD_LIBRARY_PATH}
- 编辑
./etc/conda/deactivate.d/env_vars.sh ,实现在deactivate环境的时候删除该环境变量 vim ./etc/conda/deactivate.d/env_vars.sh
#!/bin/sh
export LD_LIBRARY_PATH=${OLD_LD_LIBRARY_PATH}
unset OLD_LD_LIBRARY_PATH
参考:
- https://stackoverflow.com/questions/69917132/could-not-load-dynamic-library-libcudart-so-11-0-in-conda-enviroment
- https://stackoverflow.com/questions/46826497/conda-set-ld-library-path-for-env-only
|