Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not locate zlibwapi.dll. Please make sure it is in your library path

Tags:

opencv

zlib

gpu

I am working on a object detection project and wanting to process the project with my GPU. I have completed the NVIDIA setup tutorial and everything works fine. My object detection code originally works with the CPU, however when I add these two lines of code:

net.setPreferableBackend(cv2.dnn.DNN_BACKEND_CUDA)
net.setPreferableTarget(cv2.dnn.DNN_TARGET_CUDA)

the output displayed:

Could not locate zlibwapi.dll. Please make sure it is in your library path!

I have downloaded the zlibwapi.dll zip file stated from the cuDNN website, unzip and added the whole folder into my environment variables paths. The folder is called "zlib123dllx64" containing a "dll_x64" folder and a "static_x64" folder. The "zlibwapi.dll" is inside the "dll_x64" folder. I have added the "zlib123dllx64" folder in the user and system path variable but it doesn't seem to fix any of the problems. How can I fix this error and make the GPU work with the code?

My environment setup:

  • Windows 10
  • Visual studio community 2019
  • OpenCV Python yolov3
like image 518
Ron Avatar asked Nov 17 '25 19:11

Ron


2 Answers

I was able to find a copy of the missing zlib DLL in the NVIDIA Nsight directory:

C:\Program Files\NVIDIA Corporation\Nsight Systems 2022.4.2\host-windows-x64\zlib.dll

I copied and renamed it to:

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\bin\zlibwapi.dll

since that was already in my PATH environment variable. Doing that resolved my error.

I saw the link in the CUDNN documentation that was linked in the other answers, but I was a little concerned by the security warnings.

like image 80
user120675 Avatar answered Nov 20 '25 13:11

user120675


Windows Environment:

I faced this issue of "Could not locate zlibwapi.dll. Please make sure it is in your library path" when I am trying to run a TensorRT sample, int8_caffe_mnist. To confirm proper installation of TensorRT.

Following the instructions from: https://docs.nvidia.com/deeplearning/cudnn/install-guide/index.html#prerequisites-windows

Under 3.1.3 download zlib and add the path to the environment variables. I did the following:

  1. Windows search for Edit the system environment variables
  2. Add library path, Environment Variables -> Path -> Edit -> C:path to\zlibwapi.dll

Conclusion: Following the instructions for adding zlibwapi.dll to the path did not work for me.

Solution that worked for me:

  1. Removed the library path under Environment variables
  2. copied zlibwapi.dll to C:\Windows\System32 and C:\Windows\SysWOW64
  3. Either delete/keep zlib123dllx64 file, I choose to delete as it does not need the location to library path
like image 25
Enzo Avatar answered Nov 20 '25 11:11

Enzo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!