14

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
talonmies
  • 70,661
  • 34
  • 192
  • 269
Ron
  • 173
  • 1
  • 1
  • 9

8 Answers8

22

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
Enzo
  • 231
  • 1
  • 4
  • You save me, it work well for me. If just download zilwapi.dll, this url is more direct: https://docs.nvidia.com/deeplearning/cudnn/install-guide/index.html#install-zlib-windows – John Wu Jan 05 '23 at 23:58
  • Chrome wouldn't download through the link on Nvidia's website "ZLIB DLL". I had to right click the link and click "Save as...". Also, environment variables are paths. You should have added a line into your system path environment variable "C:\Path\To\ZLIB\dll_x64", the folder that contains `zlibwapi.dll`. You can then open `cmd` and type `zlibwapi.dll` and it will complain the file isn't executible, meaning it was found. – JoseOrtiz3 May 20 '23 at 19:12
19

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.

user120675
  • 313
  • 2
  • 7
3

Stumbled across this problem too and there is an easy fix that immediately worked for me:

Check out Nvidia's page (exact link where to download) and download.

Extract the files and simply find the single file "zlibwapi.dll". Copy this file to

C:/path to/NVIDIA GPU Computing Toolkit / CUDA/ v11.X / bin -> right here in that folder

Just did those two steps and it's TF can properly use GPU.

Guenter
  • 465
  • 1
  • 3
  • 14
2

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

Ron
  • 173
  • 1
  • 1
  • 9
2

Download and extract the zlib package from http://www.winimage.com/zLibDll/zlib123dllx64.zip for 64 bit windows then copy the zlibdll file into cudnn/bin

0

Didn't find zlibwapi.dll in bin but solved it anyhow.

Since I didn't have it in

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\

I couldn't change environment variable but I found it elsewhere.

mhartlove suggested here:

https://forums.developer.nvidia.com/t/could-not-load-library-cudnn-cnn-infer64-8-dll-error-code-193/218437/17

Solution:

"I found a copy of the 64 bit zlibwapi.dll hiding under a different name in: 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 folder is already in my PATH variable; and it worked. Turns out the CUDA Toolkit already has the file you need elsewhere. Seems like they could save a lot of trouble if they just made a change to the CUDA Toolkit installer. "

0

Do not download zip files from random websites as they could contain malicious code.

I don't know why nvidia is hiding it that good but here's an official answer with matching downloads that worked for me:

Waescher
  • 5,361
  • 3
  • 34
  • 51
-1

I downloaded the dll file from https://www.dllme.com/getfile.php?file=38308&id=9b45296e316cdf31b9bace739e22ca7a

Extracted it

see here

renamed zlibwapi_x64.dll -> zlibwapi.dll

and pasted it in the bin of my CUDA

Look at the last file

This worked for me....