YOLO on Azure Deep Learning Virtual Machine (DLVM - Windows)
[video width="854" height="480" mp4="https://msdnshared.blob.core.windows.net/media/2018/03/CherryBot-Fans-short.mp4"][/video]
YOLO "You only look once" by Joseph Redmon
A state of the art real-time object detection system that works using what I can only describe as magic: https://arxiv.org/abs/1612.08242
If you've seen any of the youtube.com videos demonstrating it, you may be curious to setup a development rig and play with it yourself. However, setting up an environment isn't that simple as there are quite a few dependencies, all evolving at different cadence - depending on what you've already got installed on your machine you can end up in a bit of a mess and scratching you head as to why it's not working.
I spent a couple of hours this week setting up my Surface Book (with GPU) to experiment with YOLO. However, after doing so could only get Tiny YOLO to work as kept hitting CUDA out of memory errors. Then had a dawning moment, why don't I just use Azure's Deep Learning Virtual Machine (DLVM) with GPU? Here is a guide to getting your own DLVM setup working with YOLO.
Note: There are numerous guides out there to walk through setting up a Windows development environment for YOLO. I strongly encourage you to read the following first: https://pjreddie.com/darknet/ and https://github.com/AlexeyAB/darknet/blob/master/README.md.
The DVLM has a bucket load of tools already installed on it. However, there are a few updates and additional libraries you need to install to get YOLO up and running.
- Update the Visual Studio Installer
- Update Visual Studio Community 2017 (currently v15.6.4)
- Add the VC++ 2017 version 14.4 v14.11 toolset (for side by side MSVC toolsets: https://blogs.msdn.microsoft.com/vcblog/2017/11/15/side-by-side-minor-version-msvc-toolsets-in-visual-studio-2017/)
- Download OpenCV 3.40 (not higher as it won't work: https://github.com/AlexeyAB/darknet/issues/402) and extract to the path c:\opencv_3.0
- Install CUDA 9.1 https://developer.nvidia.com/cuda-downloads (Windows 2016 version for DLVM)
- Your environment variables should look like the below including CUDNN (as per: https://github.com/AlexeyAB/darknet/blob/master/README.md#how-to-compile-on-windows) which is already installed on the DLVM at the path C:\NVIDIA\cuda. You'll also need to add a system variable for OPENCV_DIR to C:\opencv_3.0\opencv\build
- Tweak the C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\include\crt\host_config.h file to update it with the latest VS version eg:
- Clone AlexyAB's fork of the darknet repo: https://github.com/AlexeyAB/darknet.git
- Copy the C:\Program Files (x86)\Microsoft Visual Studio\Preview\Community\VC\Auxiliary\Build\14.11\ props file to the darknet\build\darknet solution folder eg:
- Edit the darknet.vcxproj file to include the v14.11.props file copied above (again ref: https://blogs.msdn.microsoft.com/vcblog/2017/11/15/side-by-side-minor-version-msvc-toolsets-in-visual-studio-2017/)
- Open the darknet.sln solution - retarget the project
- Build (Release x64 bit)
- Open the solution/x64 output directory and you should see darknet.exe :)
- Copy the OpenCV dependencies into the output directory above:
- Download the YOLO9000 weights: https://pjreddie.com/media/files/yolo9000.weights
- Run solution/x64/darknet_coco_9000.cmd
Slight update 26/04/2018: After rebooting the machine at a later point I got the below error when running the darknet.exe.
"CUDA Error: CUDA driver version is insufficient for CUDA runtime version"
To get round this I just needed to re-install CUDA again (over the top)