【问题标题】:Load .txt file with pickle on non GPU machine在非 GPU 机器上使用 pickle 加载 .txt 文件
【发布时间】:2019-01-13 05:07:48
【问题描述】:

我正在尝试在 GPU 机器上加载 .txt 文件。 .txt 文件被转储到 GPU 机器上:

with open("Data/all_rewards.txt", "wb") as f:
    pickle.dump(all_rewards, f)

该文件仅包含文本数据,没有网络模型或其他任何内容。 在 GPU 机器上,我可以毫无问题地加载数据:

with open("all_rewards.txt", 'rb') as f:
    losses = pickle.load(f)

然而,在 GPU 机器上,我得到了错误:

AssertionError('Torch not compiled with CUDA enabled',)

由于 Torch 也使用 pickle 加载模型,我尝试使用以下方法加载数据:

losses = torch.load("all_rewards.txt", map_location='cpu')

但这没有用。 你能帮我吗?

编辑: 不知何故,这个问题神奇地解决了。我已经重新安装了pickle,它最初并没有解决问题,但现在它可以工作了......

【问题讨论】:

    标签: python tensorflow pickle pytorch loaddata


    【解决方案1】:

    听起来您在非 GPU 机器上安装 pytorch 的方式存在问题。除了pip install torchvision,还需要运行一个命令

    如果您前往 https://pytorch.org/ 并选择 CUDA:None 并使用您的操作系统配置,您应该会收到一个额外的 http 链接以下载额外的轮子包。

    例如:Linux、pip 和 Python3.6 导致以下附加命令

    pip3 install http://download.pytorch.org/whl/cpu/torch-0.4.1-cp36-cp36m-linux_x86_64.whl

    【讨论】:

    • 不幸的是,这并没有为我的问题带来任何解决方案。 Pickle 就是不让我加载数据。没有火炬可以使用泡菜吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-11-10
    • 2021-12-28
    • 1970-01-01
    • 2014-03-09
    • 2011-03-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多