How to install pytorch in ubuntu?

2021-8-7 写技术

conda install pytorch torchvision torchaudio cpuonly -c pytorch

1.You'd better install packages one by one.

2.After enter the command, then you may see "there are some packages will be downloaded".
If the network is not well, you'd better cancel the installing processing and then download it by some tools.
After that downloading by yourself, copy the package to "miniconda/pkgs/" directory.

3.Edit "miniconda3/lib/python3.9/site-packages/conda/gateways/connection/download.py".
Find the download function, then add some lines at the beging of it.

    from ...base.constants import CONDA_TEMP_EXTENSION

    tmp_file_path = target_full_path + CONDA_TEMP_EXTENSION
    if exists(tmp_file_path):
        print("\n[Download patch] file exists: %s", tmp_file_path)

        checksum_ok = True

        if sha256 or md5:
            builder = hashlib.new("sha256" if sha256 else "md5")
            checksum = sha256 if sha256 else md5

            with open(tmp_file_path, 'rb') as f:
                for chunk in iter(lambda: f.read(4096), b''):
                    builder.update(chunk)

            actual_checksum = builder.hexdigest()
            if actual_checksum != checksum:
                print("\n[Download patch] cached file checksum mismatch: %s (%s != %s)",
                    checksum_type, actual_checksum, checksum)
            checksum_ok = actual_checksum == checksum

        if checksum_ok:
            from ..disk.update import backoff_rename
            backoff_rename(tmp_file_path, target_full_path, True)
            if progress_update_callback:
                progress_update_callback(1.0)
            print("\n[Download patch] using cached file instead of download", target_full_path)
            return

4.Get a package information.
conda search package_name --info

标签: DL

发表评论:

Powered by anycle 湘ICP备15001973号-1