8000 ```grad_mode.py``` torch imported as NoneType, cannot import ```torch._jit_internal``` · Issue #154114 · pytorch/pytorch · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
grad_mode.py torch imported as NoneType, cannot import torch._jit_internal #154114
Open
@Shir0-Kage

Description

@Shir0-Kage

🐛 Describe the bug

When importing 'torch' in grad_mode.py, it is imported as a NoneType, and the line

if not torch._jit_internal.is_scripting():

causes the following error:

Traceback (most recent call last):
  File "E:\Coding\.venv\lib\site-packages\torch\utils\_contextlib.py", line 45, in generator_context
  File "E:\Coding\.venv\lib\site-packages\torch\utils\_contextlib.py", line 148, in clone
  File "E:\Coding\.venv\lib\site-packages\torch\autograd\grad_mode.py", line 76, in __init__
AttributeError: 'NoneType' object has no attribute '_jit_internal'

These are the imports found in grad_mode.py:

from typing import Any, Union

import torch
from torch.utils._contextlib import (
    _DecoratorContextManager,
    _NoParamDecoratorContextManager,
    F,
)

Is this an issue with the compiler?

Versions

PyTorch version: 2.7.0+cu126
Is debug build: False
CUDA used to build PyTorch: 12.6
ROCM used to build PyTorch: N/A

OS: Microsoft Windows 11 Pro (10.0.26100 64-bit)
GCC version: Could not collect
Clang version: Could not collect
CMake version: Could not collect
Libc version: N/A

Python version: 3.10.11 (tags/v3.10.11:7d4cc5a, Apr 5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)] (64-bit runtime)
Python platform: Windows-10-10.0.26100-SP0
Is CUDA available: True
CUDA runtime version: 12.9.41
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 4080 Laptop GPU
Nvidia driver version: 576.52
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Name: AMD Ryzen 9 7940HS w/ Radeon 780M Graphics
Manufacturer: AuthenticAMD
Family: 107
Architecture: 9
ProcessorType: 3
DeviceID: CPU0
CurrentClockSpeed: 4001
MaxClockSpeed: 4001
L2CacheSize: 8192
L2CacheSpeed: None
Revision: 29697

Versions of relevant libraries:
[pip3] numpy==2.2.6
[pip3] > [pip3] pytorch-lightning==2.5.1.post0
[pip3] pytorch-wpe==0.0.1
[pip3] torch==2.7.0+cu126
[pip3] torch-complex==0.4.4
[pip3] torchaudio==2.7.0+cu126
[pip3] torchmetrics==1.7.1
[pip3] torchvision==0.22.0+cu126
[pip3] triton-windows==3.3.0.post19
[conda] Could not collect

cc @peterjc123 @mszhanyi @skyline75489 @nbcsm @iremyux @Blackhex @ezyang @albanD @gqchen @nikitaved @soulitzer @Varal7 @xmfan

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: autogradRelated to torch.autograd, and the autograd engine in generalmodule: python frontendFor issues relating to PyTorch's Python frontendmodule: windowsWindows support for PyTorchneeds reproductionSomeone else needs to try reproducing the issue given the instructions. No action needed from usertriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0