[Python] Why I face the "UserWarning: The NumPy module was reloaded (imported a second...

Discussão em 'Python' iniciado por Stack, Junho 5, 2025.

  1. Stack

    Stack Membro Participativo

    My environment: Anaconda, Python 3.8.8, Pytorch1.8.1+cu111
    Question: When I run the code below I get the following error:

    UserWarning: "D:\Anaconda3\envs\pytorch\lib\site-packages\torch\cuda\amp\autocast_mode.py:5: UserWarning: The NumPy module was reloaded (imported a second time). This can in some cases result in small but subtle issues and is discouraged."


    Code:

    from PIL import Image
    from torchvision import transforms

    img_path = "data/train/ants_image/0013035.jpg"
    img = Image.open(img_path)

    tensor_trains = transforms.ToTensor()
    tensor_img = tensor_trains(img)

    print(tensor_img)


    But the code work. Why does the above error message appear?

    Continue reading...

Compartilhe esta Página