Skip to content

windows pip installation doesn't find openCL cpu drivers properly #1751

Closed

Description

@icfaust

In this github action example, the conda environment can properly access the installed opencl driver, but pip cannot:

name: pip dpctl validator
on:
  workflow_dispatch:

env:
  PYTHON_VERSION: 3.9
  DPCTL_VERSION: 0.17.0

jobs:
  dpctl:
    name: dpctl_test
    runs-on: windows-2022
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Install Python
        uses: actions/setup-python@v5
        with:
          python-version: ${{ env.PYTHON_VERSION }}
      - name: Install dpctl
        shell: cmd
        run: |
          set PATH=C:\msys64\usr\bin;%PATH%
          python -m venv env2
          call .\env2\Scripts\activate.bat
          set DPCTL_SUPPORTED=3.9 3.11
          FOR %%i IN (%DPCTL_SUPPORTED%) DO if ${{ env.PYTHON_VERSION }}==%%i python -m pip install --index-url https://pypi.anaconda.org/intel/simple dpctl==0.17.0
          python -c "import os, os.path, site; path_to_env = site.getsitepackages()[0]; path_to_libs = os.path.join(path_to_env, 'Library', 'bin'); temp=os.add_dll_directory(path_to_libs) if os.path.exists(path_to_libs) else None; import dpctl; print(dpctl.get_devices())"
          python -c "import dpctl; print(dpctl.lsplatform(2))"
          pip list
      - name: Install dpctl conda
        shell: cmd
        run: |
          set PATH=C:\msys64\usr\bin;%PATH%
          call C:\Miniconda\condabin\conda.bat config --add channels https://software.repos.intel.com/python/conda/
          call C:\Miniconda\condabin\conda.bat config --append channels conda-forge
          call C:\Miniconda\condabin\conda.bat create --name dpctl_env dpctl
          call C:\Miniconda\condabin\conda.bat activate dpctl_env
          python -c "import dpctl; print(dpctl.lsplatform(2))"

By installing the opencl cpu driver from here: and including the following path:

  set PATH="C:\Program Files (x86)\Common Files\Intel\Shared Libraries\bin;"%PATH%

The pip version can recover the CPU sycl device.

Could be this is an upstream issue with intel-opencl-rt repository? Either a warning needs to be added to the documentation that the drivers must be installed separately in the pip path, or this would need to be fixed.

Activity

  1. changed the title [-]windows pip installation doesn't link openCL cpu drivers properly[/-] [+]windows pip installation doesn't find openCL cpu drivers properly[/+] on Jul 22, 2024
  2. oleksandr-pavlyk commented on Jul 24, 2024

    @oleksandr-pavlyk
    Contributor

    @icfaust This is because in conda, activation script is doing set "OCL_ICD_FILENAMES=%CONDA_PREFIX%\Library\bin\intelocl64.dll" . This step must be performed manually when using pip as package manager.

    It may also be necessary to use os.add_dll_directory to ensure that the CPU driver is able to find the required TBB libraries in the Python layout.

  3. icfaust commented on Jul 29, 2024

    @icfaust
    Author

    Let me try this out on the github runner example to verify if this works.

  4. icfaust commented on Jul 30, 2024

    @icfaust
    Author

    It didn't seem to work...

  5. oleksandr-pavlyk commented on Jul 30, 2024

    @oleksandr-pavlyk
    Contributor

    @icfaust If you are attempting this in GitHub action runners, you need to take into account that the Python script is executed in a session with elevated privileges. OpenCL loader, for security purposes, ignores environment variable values.

    To make location of CPU implementation library, e.g., %CONDA_PREFIX%\Library\bin\intelocl64.dll known to the loader, information must be provided through Windows registry, see https://github.com/IntelPython/dpctl/blob/master/.github/workflows/conda-package.yml#L317-L318

    The content of the script file "set-intel-ocl-icd-registry.ps1" is as follow:

    #Requires -RunAsAdministrator
    
    $conda_env_library = "$env:CONDA_PREFIX\Library"
    
    if (-not (Test-Path -Path HKLM:\SOFTWARE\Khronos)) {
        New-Item -Path HKLM:\SOFTWARE\Khronos
    }
    if (-not (Test-Path -Path HKLM:\SOFTWARE\Khronos\OpenCL)) {
        New-Item -Path HKLM:\SOFTWARE\Khronos\OpenCL
    }
    if (-not (Test-Path -Path HKLM:\SOFTWARE\Khronos\OpenCL\Vendors)) {
        New-Item -Path HKLM:\SOFTWARE\Khronos\OpenCL\Vendors
    }
    New-ItemProperty -Path HKLM:\SOFTWARE\Khronos\OpenCL\Vendors -Name $conda_env_library\bin\intelocl64.dll -Value 0
    
    Write-Host "Registry value: $(Get-Item -Path HKLM:\SOFTWARE\Khronos\OpenCL\Vendors)"
  6. oleksandr-pavlyk commented on Dec 2, 2024

    @oleksandr-pavlyk
    Contributor

    @icfaust please close unless the issue remains unresolved

  7. icfaust commented on Dec 3, 2024

    @icfaust
    Author

    Ah sorry about that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions