dpnp icon indicating copy to clipboard operation
dpnp copied to clipboard

` SyclDeviceCreationError: Default device is unavailable.` when attempting to use dpnp 0.18.1 on google colab

Open ogrisel opened this issue 3 months ago • 3 comments

Steps to reproduce:

  • Open a new colab notebook
  • Check the CPU architecture with !lscpu
  • Output of lscpu:
Architecture:                x86_64
  CPU op-mode(s):            32-bit, 64-bit
  Address sizes:             46 bits physical, 48 bits virtual
  Byte Order:                Little Endian
CPU(s):                      2
  On-line CPU(s) list:       0,1
Vendor ID:                   GenuineIntel
  Model name:                Intel(R) Xeon(R) CPU @ 2.20GHz
    CPU family:              6
    Model:                   79
    Thread(s) per core:      2
    Core(s) per socket:      1
    Socket(s):               1
    Stepping:                0
    BogoMIPS:                4400.39
    Flags:                   fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pg
                             e mca cmov pat pse36 clflush mmx fxsr sse sse2 ss h
                             t syscall nx pdpe1gb rdtscp lm constant_tsc rep_goo
                             d nopl xtopology nonstop_tsc cpuid tsc_known_freq p
                             ni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2ap
                             ic movbe popcnt aes xsave avx f16c rdrand hyperviso
                             r lahf_lm abm 3dnowprefetch ssbd ibrs ibpb stibp fs
                             gsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invp
                             cid rtm rdseed adx smap xsaveopt arat md_clear arch
                             _capabilities
Virtualization features:     
  Hypervisor vendor:         KVM
  Virtualization type:       full
Caches (sum of all):         
  L1d:                       32 KiB (1 instance)
  L1i:                       32 KiB (1 instance)
  L2:                        256 KiB (1 instance)
  L3:                        55 MiB (1 instance)
NUMA:                        
  NUMA node(s):              1
  NUMA node0 CPU(s):         0,1
Vulnerabilities:             
  Gather data sampling:      Not affected
  Indirect target selection: Vulnerable
  Itlb multihit:             Not affected
  L1tf:                      Mitigation; PTE Inversion
  Mds:                       Vulnerable; SMT Host state unknown
  Meltdown:                  Vulnerable
  Mmio stale data:           Vulnerable
  Reg file data sampling:    Not affected
  Retbleed:                  Vulnerable
  Spec rstack overflow:      Not affected
  Spec store bypass:         Vulnerable
  Spectre v1:                Vulnerable: __user pointer sanitization and usercop
                             y barriers only; no swapgs barriers
  Spectre v2:                Vulnerable; IBPB: disabled; STIBP: disabled; PBRSB-
                             eIBRS: Not affected; BHI: Vulnerable
  Srbds:                     Not affected
  Tsa:                       Not affected
  Tsx async abort:           Vulnerable
  • Install dpnp %pip install --index-url https://software.repos.intel.com/python/pypi dpnp
  • Installed versions:
Successfully installed dpcpp-cpp-rt-2025.2.0 dpctl-0.20.2 dpnp-0.18.1 intel-cmplr-lib-rt-2025.2.0 intel-cmplr-lib-ur-2025.2.0 intel-cmplr-lic-rt-2025.2.0 intel-opencl-rt-2025.2.0 intel-openmp-2025.2.0 intel-sycl-rt-2025.2.0 onemkl-sycl-blas-2025.2.0 onemkl-sycl-dft-2025.2.0 onemkl-sycl-lapack-2025.2.0 onemkl-sycl-rng-2025.2.0 onemkl-sycl-stats-2025.2.0 onemkl-sycl-vm-2025.2.0
  • Attempt to use it with the default device (e.g. import dpnp; dpnp.ones(3))

  • Get the following SyclDeviceCreationError: Default device is unavailable.

  • Full traceback:

---------------------------------------------------------------------------
SyclDeviceCreationError                   Traceback (most recent call last)
[/tmp/ipython-input-2008473604.py](https://github.com/IntelPython/dpnp/issues/new#) in <cell line: 0>()
      1 import dpnp
      2 
----> 3 dpnp.ones(3)

4 frames[/usr/local/lib/python3.12/dist-packages/dpnp/dpnp_iface_arraycreation.py](https://github.com/IntelPython/dpnp/issues/new#) in ones(shape, dtype, order, like, device, usm_type, sycl_queue)
   3414         usm_type = "device"
   3415 
-> 3416     return dpnp_container.ones(
   3417         shape,
   3418         dtype=dtype,

[/usr/local/lib/python3.12/dist-packages/dpnp/dpnp_container.py](https://github.com/IntelPython/dpnp/issues/new#) in ones(shape, dtype, order, device, usm_type, sycl_queue)
    250     """Validate input parameters before passing them into `dpctl.tensor` module"""
    251     dpu.validate_usm_type(usm_type, allow_none=False)
--> 252     sycl_queue_normalized = dpnp.get_normalized_queue_device(
    253         sycl_queue=sycl_queue, device=device
    254     )

[/usr/local/lib/python3.12/dist-packages/dpnp/dpnp_iface.py](https://github.com/IntelPython/dpnp/issues/new#) in get_normalized_queue_device(obj, device, sycl_queue)
    560         sycl_queue = obj.sycl_queue
    561 
--> 562     return normalize_queue_device(sycl_queue=sycl_queue, device=device)
    563 
    564 

[/usr/local/lib/python3.12/dist-packages/dpctl/tensor/_device.py](https://github.com/IntelPython/dpnp/issues/new#) in normalize_queue_device(sycl_queue, device)
    170     d = device
    171     if q is None:
--> 172         d = Device.create_device(d)
    173         return d.sycl_queue
    174     if not isinstance(q, dpctl.SyclQueue):

[/usr/local/lib/python3.12/dist-packages/dpctl/tensor/_device.py](https://github.com/IntelPython/dpnp/issues/new#) in create_device(cls, device)
     75         else:
     76             if dev is None:
---> 77                 _dev = _cached_default_device()
     78             else:
     79                 _dev = dpctl.SyclDevice(dev)

dpctl/_sycl_device_factory.pyx in dpctl._sycl_device_factory._cached_default_device()

dpctl/_sycl_device_factory.pyx in dpctl._sycl_device_factory._cached_default_device()

dpctl/_sycl_device_factory.pyx in dpctl._sycl_device_factory._DefaultDeviceCache.get_or_create()

dpctl/_sycl_device_factory.pyx in dpctl._sycl_device_factory.select_default_device()

SyclDeviceCreationError: Default device is unavailable.
  • link to reproducer:

https://colab.research.google.com/drive/1nj576i49MDq3Ts_4oshz_BP48AAaRTdp?usp=sharing

ogrisel avatar Oct 08 '25 16:10 ogrisel

The issue is that there is no device visible. It looks similar to dpctl#914.

The setting "OCL_ICD_FILENAMES"="/usr/local/lib/libintelocl.so" allows OpenCL loader to find the driver. And so dpctl prints the device now:

!OCL_ICD_FILENAMES="/usr/local/lib/libintelocl.so" python -m dpctl -f
Platform  0 ::
    Name        Intel(R) OpenCL
    Version     OpenCL 3.0 LINUX
    Vendor      Intel(R) Corporation
    Backend     opencl
    Num Devices 1
      # 0
        Name                           Intel(R) Xeon(R) CPU @ 2.20GHz
        Version             2025.20.6.0.04_224945
        Filter string       opencl:cpu:0

and dpnp works fine also:

!OCL_ICD_FILENAMES="/usr/local/lib/libintelocl.so" python -c "import dpnp; a = dpnp.ones(3); print(a)"
[1. 1. 1.]

antonwolfy avatar Oct 09 '25 09:10 antonwolfy

Thanks @antonwolfy. I confirm that updating the notebook to insert the following cell before importing dpnp:

import os

os.environ["OCL_ICD_FILENAMES"] = "/usr/local/lib/libintelocl.so"

fixes the problem.

Wouldn't it possible to change the dpnp/__init__.py file to do that automatically when installed with pip install --index-url https://software.repos.intel.com/python/pypi dpnp? The location of the libintelocl.so depends on whether we install in a virtualenv or not.

ogrisel avatar Oct 09 '25 13:10 ogrisel

I don't think that dpnp init is a good place for that. It seems more proper to be a part of intel-opencl-rt package or dpctl at least.

antonwolfy avatar Oct 09 '25 13:10 antonwolfy