NVIDIA / NVIDIA/cutlass

[BUG] Cutlass python does not detect GPU

Open
#1,919 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

? - Needs Triage bug inactive-30d inactive-90d
Dominant language
C++
Stars
10.5k
Forks
2.1k
Avg merge
3d 11h
Merged PRs (30d)
7

Description

Describe the bug
I am trying to use Cutlass Python and build it from source.
My environment is formed by Ubuntu 18.04, cuda 11.8, GPU Nvidia Tesla V100 volta, python3.10, make 3.19 and GCC version 9.4.0.
I successfully built and compiled Cutlass following the guidelines here. However, I now desire to compile cutlass Python to use pytorch with a cutlass. However, when following the guidelines in /python, it fails because it does not detect the GPU.

Steps/Code to reproduce bug
I have executed pip install -e . in the root directory /cutlass, and it works fine because pip detects and compiles cutlass; in fact, if I run pip list | grep nvidia, it shows nvidia-cutlass 3.6.0.0 . However, when I run a test, or this basic example fails:

`import cutlass
import numpy as np

plan = cutlass.op.Gemm(element=np.float16, layout=cutlass.LayoutType.RowMajor)
A, B, C, D = [np.ones((1024, 1024), dtype=np.float16) for i in range(4)]
plan.run(A, B, C, D)`

And the output error is:
File "/mnt/beegfs/gap/izcagal@upvnet.upv.es/cutlass/test/python/cutlass/conv2d/test.py", line 4, in <module> plan = cutlass.op.Gemm(element=np.float16, layout=cutlass.LayoutType.RowMajor) File "/mnt/beegfs/gap/izcagal@upvnet.upv.es/cutlass/python/cutlass/op/gemm.py", line 224, in __init__ super().__init__(cc=cc, kernel_cc=kernel_cc) File "/mnt/beegfs/gap/izcagal@upvnet.upv.es/cutlass/python/cutlass/op/op.py", line 72, in __init__ self.cc = cc if cc is not None else device_cc() File "/mnt/beegfs/gap/izcagal@upvnet.upv.es/cutlass/python/cutlass/backend/utils/device.py", line 77, in device_cc device = cutlass.device_id() File "/mnt/beegfs/gap/izcagal@upvnet.upv.es/cutlass/python/cutlass/__init__.py", line 176, in device_id initialize_cuda_context() File "/mnt/beegfs/gap/izcagal@upvnet.upv.es/cutlass/python/cutlass/__init__.py", line 163, in initialize_cuda_context raise RuntimeError(f"cudaFree failed with error {err}") RuntimeError: cudaFree failed with error 3

Or if I run the tests:

`======================================================================
ERROR: conv2d_sm80 (unittest.loader._FailedTest)

ImportError: Failed to import test module: conv2d_sm80
Traceback (most recent call last):
File "/usr/lib/python3.10/unittest/loader.py", line 436, in _find_test_path
module = self._get_module_from_name(name)
File "/usr/lib/python3.10/unittest/loader.py", line 377, in _get_module_from_name
import(name)
File "/mnt/beegfs/gap/izcagal@upvnet.upv.es/cutlass/test/python/cutlass/conv2d/conv2d_sm80.py", line 50, in
@unittest.skipIf(device_cc() < cc, 'Device compute capability is invalid for SM80 tests.')
File "/mnt/beegfs/gap/izcagal@upvnet.upv.es/cutlass/python/cutlass/backend/utils/device.py", line 77, in device_cc
device = cutlass.device_id()
File "/mnt/beegfs/gap/izcagal@upvnet.upv.es/cutlass/python/cutlass/init.py", line 176, in device_id
initialize_cuda_context()
File "/mnt/beegfs/gap/izcagal@upvnet.upv.es/cutlass/python/cutlass/init.py", line 163, in initialize_cuda_context
raise RuntimeError(f"cudaFree failed with error {err}")
RuntimeError: cudaFree failed with error 3


Ran 1 test in 0.002s

FAILED (errors=1)
Traceback (most recent call last):
File "/mnt/beegfs/gap/izcagal@upvnet.upv.es/cutlass/test/python/cutlass/conv2d/run_all_tests.py", line 44, in
raise Exception('Test cases failed')
Exception: Test cases failed
izcagal@upvnet.upv.es@altek1:~/cutlass/test/python/cutlass/conv2d$ python3.10 test.py
Traceback (most recent call last):
File "/mnt/beegfs/gap/izcagal@upvnet.upv.es/cutlass/test/python/cutlass/conv2d/test.py", line 4, in
plan = cutlass.op.Gemm(element=np.float16, layout=cutlass.LayoutType.RowMajor)
File "/mnt/beegfs/gap/izcagal@upvnet.upv.es/cutlass/python/cutlass/op/gemm.py", line 224, in init
super().init(cc=cc, kernel_cc=kernel_cc)
File "/mnt/beegfs/gap/izcagal@upvnet.upv.es/cutlass/python/cutlass/op/op.py", line 72, in init
self.cc = cc if cc is not None else device_cc()
File "/mnt/beegfs/gap/izcagal@upvnet.upv.es/cutlass/python/cutlass/backend/utils/device.py", line 77, in device_cc
device = cutlass.device_id()
File "/mnt/beegfs/gap/izcagal@upvnet.upv.es/cutlass/python/cutlass/init.py", line 176, in device_id
initialize_cuda_context()
File "/mnt/beegfs/gap/izcagal@upvnet.upv.es/cutlass/python/cutlass/init.py", line 163, in initialize_cuda_context
raise RuntimeError(f"cudaFree failed with error {err}")
RuntimeError: cudaFree failed with error 3`

I would like to know if I omitted any step because I didn't modify the cuda or path variables. It was automatically detected by cmake. I just did:

$ mkdir build && cd build $ cmake .. -DCUTLASS_NVCC_ARCHS=70 $ make -j$(nproc)

And It worked fine.

Any help would be appreciated.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with python/cutlass/init.py at initialize_cuda_context and python/cutlass/backend/utils/device.py at device_cc(), then reproduce the failure using the reported Gemm example and conv2d tests. Determine whether the CUDA context error is caused by the reported environment or by Cutlass Python; done means documenting the required setup or identifying a reproducible fix validated by those tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
hpc, machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.