wangwei
wangwei

Reputation: 49

Could not load dynamic library 'libcudart.so.11.0' in conda enviroment

I use the conda comment to install tensorflow:

conda create -n tf2.6 python=3.9
conda install tensorflow-gpu=2.6

The log tells me it was succesuflly installed.Then in python when I import tensorflow, it shows Could not load dynamic library 'libcudart.so.11.0'. From the log, I found it installed cudatoolkit and cudnn when installing tensorflow. In the directory ./tf2.6/lib, there exist libcudart.so and libcudart.so.11.0. why python cannot recognize it? Some one can give some suggestions. Thank you very much.

In my conda env, there was another version tf2.5. It can work perfectly but I forgot how to installed it since it is a long time when I installed it.

Upvotes: 0

Views: 17159

Answers (2)

Abbos Abdullayev
Abbos Abdullayev

Reputation: 11

Originally solution what I found:

conda env config vars set LD_LIBRARY_PATH=$CONDA_PREFIX/lib

Source:https://github.com/tensorflow/tensorflow/issues/52988

Upvotes: 1

Shriraj Hegde
Shriraj Hegde

Reputation: 1082

I have the exact same problem, I have found a temporary solution as of now,

doing export LD_LIBRARY_PATH="$CONDA_PREFIX/lib" after activation will include libcudart.so.11.0

If you want to automate it,

add this to env-prefix/etc/conda/activate.d/env_vars.sh

#!/bin/sh

export LD_LIBRARY_PATH="$CONDA_PREFIX/lib"

This will run the script on conda activate and set LD_LIBRARY_PATH

Upvotes: 15

Related Questions