gpt4 book ai didi

python - 如何在 gpu 上运行 python 脚本

转载 作者:行者123 更新时间:2023-12-04 10:14:51 51 4
gpt4 key购买 nike

enter image description here

在我的 jupyter 笔记本中,torch.cuda.is_available()返回 True .但是当我运行 python 脚本时,python 脚本中的同一行代码返回 False .这向我表明,当我在笔记本中运行 python 脚本时,它不会默认使用 cuda。任何解决方法?

最佳答案

我使用了以下内容:

%run -i test_background-matting_image.py -m real-hand-held -i sample_data/input/ -o sample_data/output/ -tb sample_data/background/0001.png

根据 this : %run -i在 IPython 的命名空间而不是空命名空间中运行文件,即与我的 jupyter 笔记本“相同的 Python”。

关于python - 如何在 gpu 上运行 python 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61117617/

51 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com