Tensorflow import error:could not open dinamic library - tensorflow

i am using pop-os (linux) and the anaconda environment.
conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0
python3 -m pip install tensorflow
Issue:
cannot open shared object file: No such file or directory
2022-08-12 17:07:17.858229: W tensorflow/stream_executor/cuda/cuda_driver.cc:269] failed call to cuInit: UNKNOWN ERROR (303)
2022-08-12 17:07:17.858298: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (pop-os): /proc/driver/nvidia/version does not exist
2022-08-12 17:07:17.957536: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
this is screenshot,while importing tensorflow

Related

How to Set Up Tensorflow GPU on Windows 11?

I was trying to set up GPU to be compatible with Tensorflow on Windows 11 but was encountering a problem when attempting to verify that it had been setup correctly. I have a GPU driver installed and ran the following command in Miniconda under the 'tf' environment as suggested by step 5 of the Tensorflow installation instructions for Windows Native (https://www.tensorflow.org/install/pip#windows-native):
conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0
However, when I go to check that the GPU has been setup correctly, I encounter the following message:
2022-12-27 01:05:04.628568: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found
2022-12-27 01:05:04.628893: 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.
2022-12-27 01:05:06.913025: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found
2022-12-27 01:05:06.913317: W
~and then after several other lines of similar error messages~
tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudnn64_8.dll'; dlerror: cudnn64_8.dll not found
2022-12-27 01:05:06.915294: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1934] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.
Skipping registering GPU devices...
[]
I can't figure out what is wrong, given that I've merely followed the Tensorflow installation steps. Any ideas on what the problem could be or what I should try next?
Please ensure you have checked the mentioned Hardware requirements and Software requirements in the same link to enable GPU support. Also set the path to the bin directory after installing these software.
Now, follow the Step-by-step instructions to install TensorFlow with GPU setup after installing conda
conda create --name tf python=3.9
conda activate tf
conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0
pip install --upgrade pip
pip install "tensorflow-gpu<2.11"
to verify the GPU setup:
python -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"

Not showing GPU, Installed tensroflow using anaconda

I installed tensorflow using below
conda create -n gpu_env tensorflow-gpu
conda activate gpu_env
and try to check gpu with this below code:
from tensorflow.python.client import device_lib
device_lib.list_local_devices()
output shows me only cpu.
2021-04-18 20:54:47.012684: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN)to use the following CPU instructions in performance-critical operations: AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
[name: "/device:CPU:0"
device_type: "CPU"
memory_limit: 268435456
locality {
}
incarnation: 9318913720310627740
]
What should i do?
Note that tensorflow-gpu installs tensorflow v2.3.0 and currently, it does not install the conda cudnn or cudatoolkit packages. One thing you can do is install an earlier version of tensorflow, which does install cudnn and cudatoolkit, then upgrade with pip.
conda install tensorflow-gpu=2.1
pip install tensorflow-gpu==2.3.1
The tensorflow build automatically selected by Anaconda on Windows 10 during the installation of tensorflow-gpu seems to be faulty so check this workaround.

error when trying to import tensorflow GPU

here's the code that i use to check if tf.gpu is working or not
import tensorflow as tf
if tf.test.gpu_device_name():
print('Default GPU Device:{}'.format(tf.test.gpu_device_name()))
else:
print("Please install GPU version of TF")
and here's the error
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
2020-11-22 21:53:40.971514: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found
2020-11-22 21:53:40.971756: 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.
To use the GPU with Tensorflow, you must install the gpu version of Tensorflow
python -m pip install tensorflow-gpu
Make sure that you are also using a 64 bit version of python, as it will only work with those parameters.
EDIT:
As of Tensorflow 2.0+, both the CPU and GPU versions of Tensorflow have been packaged together.
To get Tensorflow to work with your GPU, you need to download cuDNN. Depending on what CUDA version you have, you will need to place some header files and some dll files in the file location of where you installed CUDA.

Error importing tensorflow , tensorflow library was compiled to use AVX instructions, but these aren't available on your machine

System information
- Linux Ubuntu 16.04
TensorFlow installed from binary (pip install)
TensorFlow version:
Python version: 3.5
Installed using virtualenv? pip? conda?: pip and virtualenv
Bazel version (if compiling from source):
GCC/Compiler version (if compiling from source):
CUDA/cuDNN version:
GPU model and memory:
Problem described
i was following the tutorial for using intel neural stick 2 for object detection https://towardsdatascience.com/speed-up-predictions-on-low-power-devices-using-neural-compute-stick-and-openvino-98f3ae9dcf41
in the example i install the prerequisites using the command
sudo ./opt/intel/computer_vision_sdk/deployment_tools/model_optimizer/install_prerequisites/install_prerequisites.sh
tensorflow was installed with the prerequisites , i also installed tensorflow using pip install , but when i run the next command
mo_tf.py \
--input_model ~/Downloads/ssd_mobilenet_v1_coco_2018_01_28/frozen_inference_graph.pb \
--tensorflow_use_custom_operations_config /opt/intel/computer_vision_sdk/deployment_tools/model_optimizer/extensions/front/tf/ssd_support.json \
--tensorflow_object_detection_api_pipeline_config ~/Downloads/ssd_mobilenet_v1_coco_2018_01_28/pipeline.config \
--data_type FP16
i get the following error
F tensorflow/core/platform/cpu_feature_guard.cc:37]
The tensorflow library was compiled to use AVX instructions, but these aren't available in your machine
Aborted (core dumped)
i am getting the same error when try and import tensorflow
what should i do to solve this error ?
The error message indicates that the machine does not support avx. Is it so? You can refer this link How to tell if a Linux machine supports AVX/AVX2 instructions? to check the same.
If your machine does not support AVX, then the solution would be to build tensorflow from source excluding those settings

cannot access GPU with tensorflow-gpu 1.8.0 conda package

I have the tensorflow and tensorflow-gpu 1.8.0 conda (not pip) packages installed in a conda environment on Ubuntu 16.04.4:
conda list t.*flow
# packages in environment at /home/lebedov/miniconda3/envs/TF:
#
# Name Version Build Channel
_tflow_180_select 1.0 gpu
tensorflow 1.8.0 py36_1 conda-forge
tensorflow-gpu 1.8.0 h7b35bdc_0
I have CUDA 9.0 installed on my system, which has a Quadro M2200 GPU. I can see the GPU listed in the output of nvidia-smi and can also access the GPU using other deep learning frameworks such as PyTorch 0.4.0, but for some reason TensorFlow doesn't seem to see it:
Python 3.6.5 | packaged by conda-forge | (default, Apr 6 2018, 13:39:56)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.4.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import tensorflow as tf
...: sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
2018-07-11 23:21:11.827064: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
Device mapping: no known devices.
2018-07-11 23:21:11.827942: I tensorflow/core/common_runtime/direct_session.cc:284] Device mapping:
If I downgrade to tensorflow-gpu 1.7.0, however, I can see the GPU. Any thoughts as to why the GPU isn't being detected by TensorFlow 1.8.0?
The tensorflow 1.8.0 packages from Anaconda appear to support GPUs properly, but those from conda-forge do not; see this issue.
I also had similar instances where the tensorflow-gpu won't run on default.
As for me, I solved it by just uninstalling tensorflow and only keeping tensorflow-gpu. That way, it would always run with GPU as there was no other option.
As far as compatibility is concerned, I would recommend the new conda way of installing tensorflow-gpu, which automatically installs the relevant cudnn files for you. The code would be as follows:
conda create -n [EnvironmentName] python=3.6
conda activate [EnvironmentName]
conda install -c conda-forge tensorflow-gpu==1.14
it will assess which version (CUDA,CUDNN, etc.) you require and download and install it directly to your environment. Then run your python file from this environment.
Do check afterwards with "conda list" to ensure that tensorflow-gpu is installed for you.