Skip to content

[BUG]: Second argument to ptxas_options fails to parse #668

Closed
@capybara-club

Description

@capybara-club

Is this a duplicate?

  • I confirmed there appear to be no duplicate issues for this bug and that I agree to the Code of Conduct

Type of Bug

Compile-time Error

Component

cuda.core

Describe the bug

It seems you can't pass a list with more than 1 option to ptxas_options=[...]

How to Reproduce

# Copyright (c) 2024-2025, NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED.
#
# SPDX-License-Identifier: Apache-2.0

import sys

from cuda.core.experimental import Device, LaunchConfig, Program, ProgramOptions, launch

# compute out = a * x + y
code = """
template<typename T>
__global__ void saxpy(const T a,
                      const T* x,
                      const T* y,
                      T* out,
                      size_t N) {
    const unsigned int tid = threadIdx.x + blockIdx.x * blockDim.x;
    for (size_t i=tid; i<N; i+=gridDim.x*blockDim.x) {
        out[i] = a * x[i] + y[i];
    }
}
"""

dev = Device()
dev.set_current()
s = dev.create_stream()

# prepare program
arch = "".join(f"{i}" for i in dev.compute_capability)
program_options = \
    ProgramOptions(
        std="c++11", 
        arch=f"sm_{arch}",

        # ptxas_options=["-O2"]     # compiles!
        # ptxas_options=["-v"]      # compiles!
        ptxas_options=["-v","-O2"]  # "nvrtc: error: unrecognized option -O2 found"

    )

prog = Program(code, code_type="c++", options=program_options)
mod = prog.compile(
    "cubin",
    logs=sys.stdout,
    name_expressions=("saxpy<float>", "saxpy<double>"),
)

Expected behavior

from _program.py Attribuytes description:

    ptxas_options : Union[str, List[str]], optional
        Specify one or more options directly to ptxas, the PTX optimizing assembler. Options should be strings.
        For example ["-v", "-O2"].
        Default: None

Operating System

WSL2

nvidia-smi output

+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 575.57.04              Driver Version: 576.52         CUDA Version: 12.9     |
|-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA GeForce RTX 4090        On  |   00000000:01:00.0  On |                  Off |
|  0%   46C    P0             82W /  450W |    1537MiB /  24564MiB |      1%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+

+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI              PID   Type   Process name                        GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|  No running processes found                                                             |
+-----------------------------------------------------------------------------------------+

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't workingcuda.coreEverything related to the cuda.core moduletriageNeeds the team's attention

Type

No type

Projects

No projects

Relationships

None yet

    Development

    Participants

    @leofang@oleksandr-pavlyk@capybara-club

    Issue actions

      [BUG]: Second argument to ptxas_options fails to parse · Issue #668 · NVIDIA/cuda-python