Stack Exchange Network
Stack Exchange network consists of 183 Q&A communities including
Stack Overflow
, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack Exchange
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.
Sign up to join this community
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I'm getting an error in WSL while trying to use
junyanz/pytorch-CycleGAN-and-pix2pix
.
I followed all the install steps successfully on Windows 10 x64 using the steps at
PyTORCH on Windows 10: An instructional with screenshots
, then Ubuntu for Windows with GitHub desktop
How to Install and Use the Linux Bash Shell on Windows 10
.
But I'm blocked at the latest steps.
It's where I trying to download or train the model in Windows. Using for example the Ubuntu Linux prompt, I navigate manually to the appropriate place and type a following command like the one below (I also tried in su mode)
bash pretrained_models/download_pix2pix_model.sh facades_label2photo
I get an immediate error, always the same, similar to these:
root@Azure:/mnt/c/Users/vincent/Downloads/vision/pytorch-CycleGAN-and-pix2pix# bash pretrained_models/download_pix2pix_model.sh facades_label2photo
pretrained_models/download_pix2pix_model.sh: line 2: $'\r': command not found
Note: available models are edges2shoes, sat2map, and facades_label2photo
pretrained_models/download_pix2pix_model.sh: line 4: $'\r': command not found
]pecified [facades_label2photo
pretrained_models/download_pix2pix_model.sh: line 6: $'\r': command not found
mkdir: cannot create directory ‘./checkpoints/facades_label2photo\r_pretrained\r’: No such file or directory
pretrained_models/download_pix2pix_model.sh: line 10: $'\r': command not found
WARNING: timestamping does nothing in combination with -O. See the manual
for details.
: No such file or directoryhphoto
pretrained_models/download_pix2pix_model.sh: line 12: $'\r': command not found
pretrained_models/download_pix2pix_model.sh: line 13: $'\r': command not found
Any idea?
–
–
–
–
–
–
Open your shell file on NotePad++
Click on Edit on Top bar menu, then choose EOL Conversion --> Unix(LF)
Now copy this file in your Linux system and it should run without these errors.
–
–
steeldriver is correct that the problem is that you have files with Windows line endings and bash
cannot run them. $'\r'
is a representation of the carriage return character (CR) that is part of traditional DOS and Windows line endings (CR LF), but which is absent in traditional Unix-style line endings (LF).
As you say, you're typing the command to attempt to run the script in bash
, but notice that the script is actually stored outside your Ubuntu (WSL) system, in your Windows download directory:
/mnt/c/Users/vincent/Downloads/vision/pytorch-CycleGAN-and-pix2pix
WSL paths that start with /mnt/c
, where c
may be any Windows drive letter, are paths that access files and directories outside the Ubuntu system. As a Windows path, that is:
C:\Users\vincent\Downloads\vision\pytorch-CycleGAN-and-pix2pix
That a file is stored in your Windows system outside the area where Ubuntu is installed does not guarantee that it uses Windows-style instead of Unix-style line endings. However, if you downloaded the files with Git in Windows, its default configuration is to give you Windows-style line endings.
The easiest way to fix the problem is really to just download the files you need inside the Ubuntu system from your bash
prompt. I recommend you fully update the Ubuntu system, then install git
in Ubuntu, as well as build-essential
which provides useful tools that you need to compile most software from source code. For Python programs, you may not need build-essential
; you can omit it if you like, but I suspect you'll end up needing it at some point.
sudo apt update && sudo apt upgrade && sudo apt install git build-essential
Then use the cd
command to go to a directory where you would like to download the software. This should be a directory within your Ubuntu system. For example, it could be your Ubuntu home directory or somewhere inside there. Once there, clone the repository from GitHub. I did it inside the src
directory that I made inside my home directory.
cd ~/src
git clone https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix.git
Of course, you will most likely have to install the dependencies first. To do that, just follow all the official instructions. Do all those steps within the Ubuntu system.
–
I ran into this issue and the solution was to configure git to checkout specific files in Linux line-ending way.
You can add a file to your git root directory name .gitattributes
which configure specific attributes for git (see full documentation).
Add the lines
# Convert to LF line endings on checkout.
*.sh text eol=lf
To configure git to checkout .sh
files with LF line ending even on Windows machines.
–