how to install SMAC in WSL?

小咪咪 2023-02-12 12:29 90阅读 0赞

In WSL,we build the python environment by anaconda and for debuging the code in the GUI, we install VS code.

Note:Select Ubuntu 18.04 in Microsoft Store instead of 20.04. At present, the 20.04 version is not stable, and swig, in it, is forced to be version 4.0 when installing SMAC when input the command ‘sudo apt get install build essential swig’ ,resulting in the segmentation fault (core dumped) .

目录

1 Install WSL

2 Install anaconda

3 SMAC

3.1 install SMAC

3.2 test SMAC

4 Install VS code


1 Install WSL

You need to go to control panel \ all control panel items \ programs and functions to select enable or disable windows functions

watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3BvdHVuNzg5MA_size_16_color_FFFFFF_t_70

Locate the windows subsystem for Linux and tick it, then make sure to choose restart now

20200526095505366.png

Select Ubuntu 18.04 in Microsoft Store. At present, the 20.04 version is not stable, and swig, in it, is forced to be version 4.0 when installing SMAC when input the command ‘sudo apt get install build essential swig’ ,resulting in the segmentation fault (core dumped) .

watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3BvdHVuNzg5MA_size_16_color_FFFFFF_t_70 1

Set user and password. Note: password is invisible

20200526095633735.png

2 Install anaconda

Download Anaconda Linux version to D: \ Anaconda \ Anaconda 2-4.2.0-linux-x86_ 64.sh

You can access resources under windows in WSL, and windows resources are mounted under / MNT.

Therefore, enter disk D through / MNT / d.

  1. cd /mnt/d
  2. bash Anaconda3-2020.02-Linux-x86_64.sh

If right, the situation will be:

Welcome to Anaconda2 4.2.0(by Continuum Analytics, Inc.)

In order to continue the installation process, please review the license agreement.

Please, press ENTER to continue>>>

Then go on all the way, and you will be prompted with the installation path, which will be used later:

Anaconda3 will now be installed in to this location:/home/aaa/anaconda3

Continue the installation until:

Do you wish the installer to initialize Anaconda3

by running conda init? [yes|no]

choose ‘no’

Enter command to create environment variable:

  1. export PATH="$PATH:/home/xxx/anaconda3/bin"

Input ‘python’, and the installation is successful as follows:

20200526095903746.png

3 SMAC

3.1 install SMAC

cd to the folder under your own name, the general software is installed here

  1. cd ~
  2. cd /home/xxx
  3. sudo apt-get install software-properties-common
  4. sudo apt-get update
  5. sudo apt-get install build-essential swig

It shows that version 3.0.12 is correct, and version 3. X is OK

watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3BvdHVuNzg5MA_size_16_color_FFFFFF_t_70 2

  1. conda install gxx_linux-64 gcc_linux-64 swig
  2. curl https://raw.githubusercontent.com/automl/smac3/master/requirements.txt | xargs -n 1 -L 1 pip install
  3. pip install smac

if occurs the error: ‘curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused’

maybe need to ping the address:

[Enter IPAddress.com Home page, entering raw.githubusercontent.com Find the real IP address] e.g. 199.232.68.133

if not install vim,please install vim first.

  1. sudo vi /etc/hosts

Enter the interface, add 199.232.68.133 raw.githubusercontent.com . Press : wq to save and exit

  1. 199.232.68.133 raw.githubusercontent.com

After saving and exiting, type the following commands again: on the command line to complete the installation of smac on the command side

  1. curl https://raw.githubusercontent.com/automl/smac3/master/requirements.txt | xargs -n 1 -L 1 pip install
  2. pip install smac

it will occur’Successfully installed smac -0.12.2’:

20200526101454283.png

3.2 test SMAC

Note: if want to run in tensorflow environment, activate tensorflow first

  1. pip install scikit-optimize
  2. pip install retry
  3. git clone https://github.com/automl/SMAC3
  4. cd SMAC3
  5. cd examples/branin
  6. python ../../scripts/smac --scenario scenario.txt

watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3BvdHVuNzg5MA_size_16_color_FFFFFF_t_70 3

Now, the installation is completed by the command. If you want to debug the code on GUI, it is recommended to install VS code

4 Install VS code

Input the command: ‘code.’ The VS code will be started. If it is not installed, it will be automatically installed and then started

  1. code .

After the installation is opened automatically, install the plug-in and python running environment first. Here, Anaconda extension pack is recommended. After the plug-in installation is completed, prompt “reload”. Click OK

20200526100841703.png

Then open brain.py File, run, reflect need to load launch.json , OK, click run again

watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3BvdHVuNzg5MA_size_16_color_FFFFFF_t_70 4

You can also run it in the debug window to debug the code

watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3BvdHVuNzg5MA_size_16_color_FFFFFF_t_70 5

I have been pounding drums for many days according to the following links. If operations above are not clear, please refer to:

1 https://github.com/automl/SMAC3/issues

2 https://github.com/automl/auto-sklearn/issues

3 https://automl.github.io/SMAC3/master/installation.html

4 WSL安装anaconda https://www.jianshu.com/p/ad49c4405fe7

5 raw.githubusercontent https://www.cnblogs.com/jeshy/p/12353188.html

发表评论

表情:
评论列表 (有 0 条评论,90人围观)

还没有评论,来说两句吧...

相关阅读