has_gpu

has_gpu()[source]

Detect if the runtime has GPU.

This function calls torch function underneath. To mask an environment to have no GPU, you can set “CUDA_VISIBLE_DEVICES” environment variable to empty before running the python script.

Returns:

True if the current runtime environment has GPU, False otherwise.

Return type:

bool