Skip to content

Instantly share code, notes, and snippets.

View nup002's full-sized avatar

Magne Lauritzen nup002

View GitHub Profile
@nup002
nup002 / import_optional_cupy.py
Last active February 9, 2024 07:59
A code snippet to import optional cupy
"""
This Gist illustrates how you can import cupy when it may or not be installed. Also works with frozen applications.
If cupy is not installed, or the CUDA_PATH system variable is not set, or the incorrect CUDA version is installed
(relevant for frozen applications), is_cupy_available = False.
"""
import warnings
is_cupy_available = False

Keybase proof

I hereby claim:

  • I am nup002 on github.
  • I am maggel (https://keybase.io/maggel) on keybase.
  • I have a public key ASD11eyRca9f5kSF37f1h4VEHQ27Tv0Fn_NUSCdeVXzNYgo

To claim this, I am signing this object: