We are trying to use GPU libraries for pytorch and cuda on a python compute module. We are trying to detect GPU access in the compute module, but the function to detect ability to use GPU via pytorch is returning false. When I check the lockfile of the repo, it seems like we are running into this error where the CPU-only packages are installed. However, the suggested fix in a code workspace is to set the job to run with a GPU directly in the repo, which makes sense for something like a Jupyter notebook. However, with a compute module, you set up the GPU after the container has already been built. Is there a way to force my compute module python repo to compile with the GPU-relevant libraries so that I can leverage the GPU inside my compute module? Any examples for how to use the GPU from within a python compute module?
Hello,
After enabling a gpu for your compute module, the driver is (should be) installed automatically.
Conda packages will not detect it but pip packages will. A minimal meta.yaml file can look like this:
package:
name: “conda-deployed-app”
version: “{{ PACKAGE_VERSION }}”
source:
path: ../src
requirements:
pip:
- torch==2.10.0
build:
- python=3.12.13
- setuptools
run:
# General
- python=3.12.13
- compute-modules=0.36.0
build:
script: python setup.py install --single-version-externally-managed --record=record.txt
about:
license_file: LICENSE.txt
pip downloads the torch gpu version and all required dependencies.
Be advised the commit and publish workflow takes a long time due to this.
You may need to increase the timeout for the publish workflow. Its located in the hidden ci.yml file. 45 mins should be ok:
jobs:
foundry-publish:
timeout: 45 minutes
Kind regards,
Milan