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

Viewed 10574

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
3 Answers

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

If anyone also got the same problem as me, I managed to fix the problem. Instead of calling the whole "zlib123dllx64" folder into the system environment path, you simply just add the "zlibwapi.dll" inside the "dllx64" folder into your project folder and include it in your project. This fixed my problem. cheers

Related