Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

fix windows dll search path in python 3.8 #18362

Merged
merged 2 commits into from
May 20, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion python/mxnet/libinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import os
import platform
import logging

import sys

def find_lib_path(prefix='libmxnet'):
"""Find MXNet dynamic library files.
Expand Down Expand Up @@ -73,6 +73,11 @@ def find_lib_path(prefix='libmxnet'):
'List of candidates:\n' + str('\n'.join(dll_path)))
if os.name == 'nt':
os.environ['PATH'] = os.environ['PATH'] + ';' + os.path.dirname(lib_path[0])
if sys.version_info >= (3, 8):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's more pythonic to use try-except syntax and just attempt to call add_dll_directory
It will ensure compatibility with interpreters different to cpython

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check the version here because only 3.8 or above needs to call this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's nevertheless bad practice as there are other python interpreters with different versioning schemes

if 'CUDA_PATH' not in os.environ:
raise RuntimeError('Cannot find the env CUDA_PATH.Please set CUDA_PATH env with cuda path')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thus mxnet won't work on Windows as long as users don't set up this environment variable? Or is it provided by default by cuda?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cuda default provided.

os.add_dll_directory(os.path.dirname(lib_path[0]))
os.add_dll_directory(os.path.join(os.environ['CUDA_PATH'], 'bin'))
return lib_path

def find_include_path():
Expand Down