-
Notifications
You must be signed in to change notification settings - Fork 29
Support dpctl in virtual environment on Windows out of the box #1922
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Since location of Library\bin in virtual environment is not on the default search path, importing of dpctl failes due to unmet dependencies for native extensions of dpctl submodules. This change introduces _init_helper.py which implements the following logic using built-in os Python module: 1. If os.add_dll_directory exists, and VIRTUAL_ENV environment variable is set, and os.path.join(os.environ["VIRTUAL_ENV"], "Library", "bin") exists, call os.add_dll_directory with that directory. With this change the gh-1745 is fixed, and "python -m dpctl -f" works out of the box. Only GPU devices are visible, and to enable CPU device two additional steps must be performed: 1. Edit %VIRUAL_ENV%\Library\bin\cl.cfg and set CL_CONFIG_TBB_DLL_PATH variable at the bottom of the configuration file to the expanded value of %VIRUAL_ENV%\Library\bin\tbb12.dll but use forward slashes, instead of native backward slashes. 2. Append %VIRUAL_ENV%\Library\bin to the PATH using `set "PATH=%PATH%:%VIRTUAL_ENV%\Library\bin"` After these changes `python -m dpctl -f` should see CPU device.
Deleted rendered PR docs from intelpython.github.com/dpctl, latest should be updated shortly. 🤞 |
Array API standard conformance tests for dpctl=0.19.0dev0=py310hdf72452_294 ran successfully. |
@ethanglaser PR fix for the issue we talked about. |
You should be able to steer and modify the |
Co-authored-by: ndgrigorian <46709016+ndgrigorian@users.noreply.github.com>
@icfaust The
An alternative might be to configure OpenCL driver for CPU device to read |
Array API standard conformance tests for dpctl=0.19.0dev0=py310hdf72452_295 ran successfully. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Installed wheel on Windows machine and it worked out of the box, so LGTM!
@icfaust By the way, it turns out that augmenting |
Array API standard conformance tests for dpctl=0.19.0dev0=py310hdf72452_296 ran successfully. |
@oleksandr-pavlyk |
Thank you for the suggestion @ndgrigorian . I have pushed the change to implement it, and the fix no longer relies on environment variables, alleviating security concerns. |
Use check suggested in PEP-0405 and pointed out by @ndgrigorian to compare sys.base_exec_prefix and sys.exec_prefix which would be different under virtual environment. The check that pyvenv.cfg exists is retained.
16c3f9d
to
c6eea90
Compare
Array API standard conformance tests for dpctl=0.19.0dev0=py310hdf72452_297 ran successfully. |
1 similar comment
Array API standard conformance tests for dpctl=0.19.0dev0=py310hdf72452_297 ran successfully. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, tested in virtualenv on Windows and it worked.
Thanks @oleksandr-pavlyk !
Since location of "Library\bin" in the virtual environment is not on the default search path, importing of
dpctl
fails due to unmet dependencies for native extensions ofdpctl
submodules.This change introduces
"_init_helper.py"
file which implements the following logic using built-inos
Python module:os.add_dll_directory
attribute exists, andVIRTUAL_ENV
environment variable is set, andos.path.join(os.environ["VIRTUAL_ENV"], "Library", "bin")
folder exists, callos.add_dll_directory
with that directory.With this change the gh-1745 is fixed, and
python -m dpctl -f
works out of the box.Only GPU devices are visible, and to enable CPU device two additional steps must be performed:
%VIRUAL_ENV%\Library\bin\cl.cfg
and setCL_CONFIG_TBB_DLL_PATH
variable at the bottom of the configuration file to the expanded value of%VIRUAL_ENV%\Library\bin\tbb12.dll
but use forward slashes, instead of native backward slashes.%VIRUAL_ENV%\Library\bin
to thePATH
usingset "PATH=%PATH%:%VIRTUAL_ENV%\Library\bin"
After these changes
python -m dpctl -f
should see CPU device.@icfaust