Friday, August 8, 2025

Error installing pytorch - OSError: [Errno 2] No such file or directory

This error message: OSError: [Errno 2] No such file or directory is a common issue during software installations on Windows, especially with packages that have very long file paths, like PyTorch. The path you provided is extremely long, and Windows has a default limit on path length.

Here's a breakdown of the problem and the most common solutions:

The Problem: Long File Paths

The error isn't about PyTorch itself, but about a limitation in the Windows operating system. The default maximum path length on older versions of Windows is 260 characters. When the installation process tries to create a file at a path that exceeds this limit, it fails and throws this error. The path in your error message clearly exceeds this limit.

Solutions

  1. Enable Long Path Support in Windows (Recommended): This is the most effective and permanent solution for this problem. It allows the operating system to handle file paths longer than 260 characters.

    • For Windows 10/11 Home Edition:

      • Open the Registry Editor by pressing Win + R, typing regedit, and hitting Enter.

      • Navigate to: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem

      • Find the entry named LongPathsEnabled.

      • Double-click it and change the Value data from 0 to 1.

      • Restart your computer for the changes to take effect.

    • For Windows 10/11 Pro/Enterprise Edition:

      • Open the Group Policy Editor by pressing Win + R, typing gpedit.msc, and hitting Enter.

      • Navigate to: Local Computer Policy > Computer Configuration > Administrative Templates > System > Filesystem

      • Double-click on "Enable Win32 long paths".

      • Select "Enabled" and click "OK".

      • Restart your computer.

  2. Install to a Shorter Path: If you're unable to change the registry or group policy, you can try to install Python and its packages to a directory with a much shorter path. For example, instead of the default location in your user's AppData folder, you could install PyTorch and Python to C:\Python311 or a similar short path. You can use the --target flag with pip to specify a different installation directory.

  3. Use a Virtual Environment: Using a virtual environment is a good practice for Python development in general. It can also sometimes help by creating a cleaner, and potentially shorter, installation path. However, if your virtual environment is still created in a directory with a very long path, you might still encounter the same error.

PyTorch on AMD GPUs

Since you mentioned you have an AMD-based laptop, it's also important to ensure you're installing the correct version of PyTorch that supports your GPU.

  • PyTorch for AMD GPUs on Windows and Linux relies on the ROCm (Radeon Open Compute) platform.

  • The official PyTorch website's "Get Started" page provides specific commands for installing PyTorch with ROCm support. You will need to select the appropriate options for your operating system and ROCm version.

  • On Windows, a common and recommended way to get GPU acceleration with AMD cards is to use the torch-directml package, which leverages DirectML. This is often easier to set up than ROCm on Windows. You can install it with the command pip install torch-directml.

Summary

The OSError: [Errno 2] No such file or directory is almost certainly due to the path length limit on your Windows system. The best solution is to enable long path support in Windows. After that, you can proceed with the standard PyTorch installation command. If you intend to use your AMD GPU for acceleration, make sure you're following the instructions for either the ROCm or DirectML backend, depending on your setup.

Sunday, October 1, 2023

install google cloud api tools on ubuntu / debian

 

What you need before Starting 

Before the installation of the gcloud CLI, please confirm that the following conditions are met:

  • The OS release has not reached the end-of-life.

  • The apt-transport-http package is installed. If not, use the following command to install it:

    sudo apt-get install apt-transport-https ca-certificates gnupg

Installation steps

Perform the following steps to install the Google Cloud CLI:

Step 1: Add gcloud CLI distribution

Use the following command to add the gcloud CLI distribution URI as a packet source:


Step 2: Acquire the public key

You can acquire the public Key for Google Cloud by executing one of the following commands depending on the type of your distribution:

  • Execute the following command if your distribution’s apt-key command supports the --keyring argument:

Step 3: Install gcloud

Run the following command to update and install the gcloud CLI:

Step 4: Initialize the gcloud CLI

Use the following command to initialize the gcloud CLI: