如何在python中安装手电筒 [英] How to install torch in python

查看:30
本文介绍了如何在python中安装手电筒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了 pip3 install torch --no-cache-dir,几秒钟后,我得到了这个:

I tried pip3 install torch --no-cache-dir and, after few seconds, I got this:

Collecting torch
      Downloading https://files.pythonhosted.org/packages/24/19/4804aea17cd136f1705a5e98a00618cb8f6ccc375ad8bfa437408e09d058/torch-1.4.0-cp36-cp36m-manylinux1_x86_64.whl (753.4MB)
        100% |████████████████████████████████| 753.4MB 5.7MB/s 
    Exception:
    Traceback (most recent call last):
      File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 215, in main
        status = self.run(options, args)
      File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 342, in run
        requirement_set.prepare_files(finder)
      File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 380, in prepare_files
        ignore_dependencies=self.ignore_dependencies))
      File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 620, in _prepare_file
        session=self.session, hashes=hashes)
      File "/usr/lib/python3/dist-packages/pip/download.py", line 821, in unpack_url
        hashes=hashes
      File "/usr/lib/python3/dist-packages/pip/download.py", line 663, in unpack_http_url
        unpack_file(from_path, location, content_type, link)
      File "/usr/lib/python3/dist-packages/pip/utils/__init__.py", line 617, in unpack_file
        flatten=not filename.endswith('.whl')
      File "/usr/lib/python3/dist-packages/pip/utils/__init__.py", line 506, in unzip_file
        data = zip.read(name)
      File "/usr/lib/python3.6/zipfile.py", line 1338, in read
        return fp.read()
      File "/usr/lib/python3.6/zipfile.py", line 858, in read
        buf += self._read1(self.MAX_N)
      File "/usr/lib/python3.6/zipfile.py", line 948, in _read1
        data = self._decompressor.decompress(data, n)
    MemoryError

我现在应该怎么做才能安装 PyTorch?

What should I do now to install PyTorch?

我几乎尝试了谷歌上提到的所有方法.我在 Ubuntu 上工作,我也尝试使用 conda,但我无法在 conda 之外使用该软件包.

I tried almost every method mentioned on google. I am working on Ubuntu, I tried using conda too, but I am unable to use that package outside conda.

推荐答案

对于 pip 环境使用这个

For pip environment use this

pip3 install torchvision

对于 conda 环境使用这个(在 anaconda 提示符下运行这个命令)

For conda environment use this (run this command on anaconda prompt)

conda install PyTorch -c PyTorch

<小时>

更新

使用此代码关闭缓存


Update

Use this code to turn off your cache

pip3 --no-cache-dir install torchvision

pip3 install torchvision--no-cache-dir

pip install --no-cache-dir torchvision

一个一个试试

这篇关于如何在python中安装手电筒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆