KAIKETSU Developer's Diary

株式会社KAIKETSU エンジニアチームのブログです

CentOS6上でVagrantを動かそうとしてコケた話 (未解決)

はじめに

CentOSでTensorflowをやるなら、よっぽどの理由がない限りはCentOS7を用意すべき。

背景

よっぽどの理由があってCentOS6上でTensorflow-Kerasのプログラムが動かなかった。

pyenv-virtualenvで雑に環境構築をして実行しようとしたが以下のようなエラーが出た。

ImportError: /lib64/libc.so.6: version `GLIBC_2.14' not found

glibc2.14以上がいるらしいがよくよく調べたところCentOS6に入れるのはなかなか厳しいらしいようだった。 面倒なのでVagrantでUbuntu16.04を入れて動かそうということになった。

本題

VirtualBoxVagrantをインストールしていく。

下記サイトを参考にさせていただいた。 qiita.com

DKMSのインストール

EPELのリポジトリは既に追加してあったのでyumを叩くだけだった。

$ yum -y install dkms

VirtualBoxのインストール

VirtualBoxリポジトリを追加する。

$ cd /etc/yum.repos.d/
$ sudo wget http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo

リポジトリが追加できたのでyumするだけ

$ yum -y install VirtualBox-5.1

ユーザーをvboxusersグループに追加する。

$ usermod -a -G vboxusers [username]

Vagrantのインストール

https://www.vagrantup.com/downloads.html

上記のページからURLをコピーしてきてrpmを追加する。

$ sudo rpm -Uvh https://releases.hashicorp.com/vagrant/1.9.8/vagrant_1.9.8_x86_64.rpm?_ga=2.130537803.573443576.1503902023-1829921896.1503902023

インストール終わり。

以下のコマンドでVagrantのバージョンを確認できる。

$ vagrant -v

VMを作成

必ず各ゲストごとのディレクトリを作成して実行すること。

$ mkdir xenial64
$ cd xenial64
$ vagrant init ubuntu/xenial64
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

とりあえず早くたてたかったのでVagrantfileにはノータッチで起動した

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'ubuntu/xenial64' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Loading metadata for box 'ubuntu/xenial64'
    default: URL: https://vagrantcloud.com/ubuntu/xenial64
==> default: Adding box 'ubuntu/xenial64' (v20170822.0.0) for provider: virtualbox
    default: Downloading: https://vagrantcloud.com/ubuntu/boxes/xenial64/versions/20170822.0.0/providers/virtualbox.box
==> default: Successfully added box 'ubuntu/xenial64' (v20170822.0.0) for 'virtualbox'!
==> default: Importing base box 'ubuntu/xenial64'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'ubuntu/xenial64' is up to date...
==> default: Setting the name of the VM: ubuntu_default_1503914989908_8759
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: ubuntu
    default: SSH auth method: password
The guest machine entered an invalid state while waiting for it
to boot. Valid states are 'starting, running'. The machine is in the
'gurumeditation' state. Please verify everything is configured
properly and try again.

If the provider you're using has a GUI that comes with it,
it is often helpful to open that and watch the machine, since the
GUI often has more helpful error messages than Vagrant can retrieve.
For example, if you're using VirtualBox, run `vagrant up` while the
VirtualBox GUI is open.

The primary issue for this error is that the provider you're using
is not properly configured. This is very rarely a Vagrant issue.

起動しない、、、

$ vagrant status
Current machine states:

default                   gurumeditation (virtualbox)

The VM is in the "guru meditation" state. This is a rare case which means
that an internal error in VitualBox caused the VM to fail. This is always
the sign of a bug in VirtualBox. You can try to bring your VM back online
with a `vagrant up`.

statusが"gurumediation"となっており、起動しなかった。

その後

いろいろ調べていろいろやったのでやったことを箇条書きする

  • VirtualBoxのバージョン依存という記事がいくらかあったので4.3とか5.0とかをインストールし直して試した
    • 同じエラーで失敗 (gurumediationとはなんなのか)
  • CentOS7のゲストを作成しようとしてみた
    • 同じエラーで失敗
  • VirtualBoxのせいだと思ってvagrant-libvirtをインストール、KVMベースでVMを作成しようとした
    • qemuのイメージのフォーマット(?)がCentOS6では対応していないらしく失敗

八方塞がりっぽかったので諦めた。

まとめ

CentOS7を用意しよう。