Mysql 5.6 Installation errors in Mac M1 - mysql

System version - macOS Monterey (12.4)
Chip - Apple M1 Pro
Objective - I want to install mysql#5.6 using brew as per requirement. Any other methods are also welcomed.
Steps followed -
run command for installing mysql 5.6 (brew install mysql#5.6)
Warning: mysql#5.6 has been deprecated because it is not supported upstream!
Error: mysql#5.6: no bottle available!
You can try to install from source with:
brew install --build-from-source mysql#5.6
Please note building from source is unsupported. You will encounter build
failures with some formulae. If you experience any issues please create pull
requests instead of asking for help on Homebrew's GitHub, Twitter or any other
official channels
run prompted command (brew install --build-from-source mysql#5.6)
Warning: mysql#5.6 has been deprecated because it is not supported upstream!
==> Downloading https://ghcr.io/v2/homebrew/core/cmake/manifests/3.23.2
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/cmake/blobs/sha256:46711ae9d567064916561c472b94cba0e939ae72479f6f51ebe98dc6995c4422
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:46711ae9d567064916561c472b94cba0e939ae72479f6f51ebe98dc6995c4422?se=2022-07-04T12%3A45%3A00Z&sig=PNUycLoV8sRSiCs2K38VapK1SXcIrE%2######################################################################## 100.0%
==> Downloading https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.51.tar.gz
==> Downloading from https://cdn.mysql.com//Downloads/MySQL-5.6/mysql-5.6.51.tar.gz
######################################################################## 100.0%
Warning: A newer Command Line Tools release is available.
Update them from Software Update in System Preferences or run:
softwareupdate --all --install --force
If that doesn't show you any updates, run:
sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install
Alternatively, manually download them from:
https://developer.apple.com/download/all/.
You should download the Command Line Tools for Xcode 13.4.
==> Installing dependencies for mysql#5.6: cmake
==> Installing mysql#5.6 dependency: cmake
==> Pouring cmake--3.23.2.arm64_monterey.bottle.tar.gz
🍺 /opt/homebrew/Cellar/cmake/3.23.2: 3,043 files, 42.2MB
==> Installing mysql#5.6
==> Patching
==> cmake . -DCOMPILATION_COMMENT=Homebrew -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DINSTALL_DOCDIR=share/doc/mysql#5.6 -DINSTALL_INCLUDEDIR=include/mysql -DINSTALL_INFODIR=share/info -DINSTALL_M==> make
Last 15 lines from /Users/amangautam/Library/Logs/Homebrew/mysql#5.6/02.make:
[ 9%] Building C object extra/libevent/CMakeFiles/event.dir/evrpc.c.o
cd /tmp/mysqlA5.6-20220704-17683-15afkyt/mysql-5.6.51/extra/libevent && /opt/homebrew/Library/Homebrew/shims/mac/super/clang -DHAVE_CONFIG_H -DHAVE_LIBEVENT2 -DHAVE_TLSv13 -I/tmp/mysqlA5.6-20220704-17683-15afkyt/mysql-5.6.51/extra/libevent/include -I/tmp/mysqlA5.6-20220704-17683-15afkyt/mysql-5.6.51/extra/libevent/compat -I/tmp/mysqlA5.6-20220704-17683-15afkyt/mysql-5.6.51/extra/libevent -I/tmp/mysqlA5.6-20220704-17683-15afkyt/mysql-5.6.51/include -isystem /tmp/mysqlA5.6-20220704-17683-15afkyt/mysql-5.6.51/zlib -fPIC -Wno-error=deprecated-declarations -Qunused-arguments -O3 -DNDEBUG -DDBUG_OFF -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -MD -MT extra/libevent/CMakeFiles/event.dir/evrpc.c.o -MF CMakeFiles/event.dir/evrpc.c.o.d -o CMakeFiles/event.dir/evrpc.c.o -c /tmp/mysqlA5.6-20220704-17683-15afkyt/mysql-5.6.51/extra/libevent/evrpc.c
[ 9%] Linking C static library lib/libevent_extra.a
cd /tmp/mysqlA5.6-20220704-17683-15afkyt/mysql-5.6.51/extra/libevent && /opt/homebrew/Cellar/cmake/3.23.2/bin/cmake -P CMakeFiles/event_extra.dir/cmake_clean_target.cmake
cd /tmp/mysqlA5.6-20220704-17683-15afkyt/mysql-5.6.51/extra/libevent && /opt/homebrew/Cellar/cmake/3.23.2/bin/cmake -E cmake_link_script CMakeFiles/event_extra.dir/link.txt --verbose=1
/usr/bin/ar qc lib/libevent_extra.a CMakeFiles/event_extra.dir/buffer.c.o CMakeFiles/event_extra.dir/bufferevent.c.o CMakeFiles/event_extra.dir/bufferevent_filter.c.o CMakeFiles/event_extra.dir/bufferevent_pair.c.o CMakeFiles/event_extra.dir/bufferevent_ratelim.c.o CMakeFiles/event_extra.dir/bufferevent_sock.c.o CMakeFiles/event_extra.dir/event.c.o CMakeFiles/event_extra.dir/evmap.c.o CMakeFiles/event_extra.dir/evthread.c.o CMakeFiles/event_extra.dir/evutil.c.o CMakeFiles/event_extra.dir/evutil_rand.c.o CMakeFiles/event_extra.dir/evutil_time.c.o CMakeFiles/event_extra.dir/listener.c.o CMakeFiles/event_extra.dir/log.c.o CMakeFiles/event_extra.dir/signal.c.o CMakeFiles/event_extra.dir/strlcpy.c.o CMakeFiles/event_extra.dir/select.c.o CMakeFiles/event_extra.dir/poll.c.o CMakeFiles/event_extra.dir/kqueue.c.o CMakeFiles/event_extra.dir/evthread_pthread.c.o CMakeFiles/event_extra.dir/event_tagging.c.o CMakeFiles/event_extra.dir/http.c.o CMakeFiles/event_extra.dir/evdns.c.o CMakeFiles/event_extra.dir/evrpc.c.o
/usr/bin/ranlib lib/libevent_extra.a
[ 9%] Built target event_extra
[ 9%] Linking C static library lib/libevent.a
cd /tmp/mysqlA5.6-20220704-17683-15afkyt/mysql-5.6.51/extra/libevent && /opt/homebrew/Cellar/cmake/3.23.2/bin/cmake -P CMakeFiles/event.dir/cmake_clean_target.cmake
cd /tmp/mysqlA5.6-20220704-17683-15afkyt/mysql-5.6.51/extra/libevent && /opt/homebrew/Cellar/cmake/3.23.2/bin/cmake -E cmake_link_script CMakeFiles/event.dir/link.txt --verbose=1
/usr/bin/ar qc lib/libevent.a CMakeFiles/event.dir/buffer.c.o CMakeFiles/event.dir/bufferevent.c.o CMakeFiles/event.dir/bufferevent_filter.c.o CMakeFiles/event.dir/bufferevent_pair.c.o CMakeFiles/event.dir/bufferevent_ratelim.c.o CMakeFiles/event.dir/bufferevent_sock.c.o CMakeFiles/event.dir/event.c.o CMakeFiles/event.dir/evmap.c.o CMakeFiles/event.dir/evthread.c.o CMakeFiles/event.dir/evutil.c.o CMakeFiles/event.dir/evutil_rand.c.o CMakeFiles/event.dir/evutil_time.c.o CMakeFiles/event.dir/listener.c.o CMakeFiles/event.dir/log.c.o CMakeFiles/event.dir/signal.c.o CMakeFiles/event.dir/strlcpy.c.o CMakeFiles/event.dir/select.c.o CMakeFiles/event.dir/poll.c.o CMakeFiles/event.dir/kqueue.c.o CMakeFiles/event.dir/evthread_pthread.c.o CMakeFiles/event.dir/event_tagging.c.o CMakeFiles/event.dir/http.c.o CMakeFiles/event.dir/evdns.c.o CMakeFiles/event.dir/evrpc.c.o
/usr/bin/ranlib lib/libevent.a
[ 9%] Built target event
make: *** [all] Error 2
Do not report this issue to Homebrew/brew or Homebrew/core!
Error: A newer Command Line Tools release is available.
Update them from Software Update in System Preferences or run:
softwareupdate --all --install --force
If that doesn't show you any updates, run:
sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install
Alternatively, manually download them from:
https://developer.apple.com/download/all/.
You should download the Command Line Tools for Xcode 13.4.
Please create pull requests instead of asking for help on Homebrew's GitHub,
Twitter or any other official channels.
As per above response, I did system update and again ran same command (brew install --build-from-source mysql#5.6)
Running `brew update --auto-update`...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> New Formulae
editorconfig-checker
Warning: mysql#5.6 has been deprecated because it is not supported upstream!
==> Downloading https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.51.tar.gz
Already downloaded: /Users/amangautam/Library/Caches/Homebrew/downloads/050b4768f405f6217eaccbda4b2f0c5ba8ded872cf62408677fcf7883cfe82ea--mysql-5.6.51.tar.gz
==> Patching
==> cmake . -DCOMPILATION_COMMENT=Homebrew -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DINSTALL_DOCDIR=share/doc/mysql#5.6 -DINSTALL_INCLUDEDIR=include/mysql -DINSTALL_INFODIR=share/info -DINSTALL_M
==> make
Last 15 lines from /Users/amangautam/Library/Logs/Homebrew/mysql#5.6/02.make:
[ 9%] Building C object extra/libevent/CMakeFiles/event_extra.dir/evrpc.c.o
cd /tmp/mysqlA5.6-20220704-3462-1u6glir/mysql-5.6.51/extra/libevent && /opt/homebrew/Library/Homebrew/shims/mac/super/clang -DHAVE_CONFIG_H -DHAVE_LIBEVENT2 -DHAVE_TLSv13 -I/tmp/mysqlA5.6-20220704-3462-1u6glir/mysql-5.6.51/extra/libevent/include -I/tmp/mysqlA5.6-20220704-3462-1u6glir/mysql-5.6.51/extra/libevent/compat -I/tmp/mysqlA5.6-20220704-3462-1u6glir/mysql-5.6.51/extra/libevent -I/tmp/mysqlA5.6-20220704-3462-1u6glir/mysql-5.6.51/include -isystem /tmp/mysqlA5.6-20220704-3462-1u6glir/mysql-5.6.51/zlib -fPIC -Wno-error=deprecated-declarations -Qunused-arguments -O3 -DNDEBUG -DDBUG_OFF -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -MD -MT extra/libevent/CMakeFiles/event_extra.dir/evrpc.c.o -MF CMakeFiles/event_extra.dir/evrpc.c.o.d -o CMakeFiles/event_extra.dir/evrpc.c.o -c /tmp/mysqlA5.6-20220704-3462-1u6glir/mysql-5.6.51/extra/libevent/evrpc.c
[ 9%] Linking C static library lib/libevent_extra.a
cd /tmp/mysqlA5.6-20220704-3462-1u6glir/mysql-5.6.51/extra/libevent && /opt/homebrew/Cellar/cmake/3.23.2/bin/cmake -P CMakeFiles/event_extra.dir/cmake_clean_target.cmake
cd /tmp/mysqlA5.6-20220704-3462-1u6glir/mysql-5.6.51/extra/libevent && /opt/homebrew/Cellar/cmake/3.23.2/bin/cmake -E cmake_link_script CMakeFiles/event_extra.dir/link.txt --verbose=1
/usr/bin/ar qc lib/libevent_extra.a CMakeFiles/event_extra.dir/buffer.c.o CMakeFiles/event_extra.dir/bufferevent.c.o CMakeFiles/event_extra.dir/bufferevent_filter.c.o CMakeFiles/event_extra.dir/bufferevent_pair.c.o CMakeFiles/event_extra.dir/bufferevent_ratelim.c.o CMakeFiles/event_extra.dir/bufferevent_sock.c.o CMakeFiles/event_extra.dir/event.c.o CMakeFiles/event_extra.dir/evmap.c.o CMakeFiles/event_extra.dir/evthread.c.o CMakeFiles/event_extra.dir/evutil.c.o CMakeFiles/event_extra.dir/evutil_rand.c.o CMakeFiles/event_extra.dir/evutil_time.c.o CMakeFiles/event_extra.dir/listener.c.o CMakeFiles/event_extra.dir/log.c.o CMakeFiles/event_extra.dir/signal.c.o CMakeFiles/event_extra.dir/strlcpy.c.o CMakeFiles/event_extra.dir/select.c.o CMakeFiles/event_extra.dir/poll.c.o CMakeFiles/event_extra.dir/kqueue.c.o CMakeFiles/event_extra.dir/evthread_pthread.c.o CMakeFiles/event_extra.dir/event_tagging.c.o CMakeFiles/event_extra.dir/http.c.o CMakeFiles/event_extra.dir/evdns.c.o CMakeFiles/event_extra.dir/evrpc.c.o
/usr/bin/ranlib lib/libevent_extra.a
[ 9%] Built target event_extra
[ 9%] Linking C static library lib/libevent.a
cd /tmp/mysqlA5.6-20220704-3462-1u6glir/mysql-5.6.51/extra/libevent && /opt/homebrew/Cellar/cmake/3.23.2/bin/cmake -P CMakeFiles/event.dir/cmake_clean_target.cmake
cd /tmp/mysqlA5.6-20220704-3462-1u6glir/mysql-5.6.51/extra/libevent && /opt/homebrew/Cellar/cmake/3.23.2/bin/cmake -E cmake_link_script CMakeFiles/event.dir/link.txt --verbose=1
/usr/bin/ar qc lib/libevent.a CMakeFiles/event.dir/buffer.c.o CMakeFiles/event.dir/bufferevent.c.o CMakeFiles/event.dir/bufferevent_filter.c.o CMakeFiles/event.dir/bufferevent_pair.c.o CMakeFiles/event.dir/bufferevent_ratelim.c.o CMakeFiles/event.dir/bufferevent_sock.c.o CMakeFiles/event.dir/event.c.o CMakeFiles/event.dir/evmap.c.o CMakeFiles/event.dir/evthread.c.o CMakeFiles/event.dir/evutil.c.o CMakeFiles/event.dir/evutil_rand.c.o CMakeFiles/event.dir/evutil_time.c.o CMakeFiles/event.dir/listener.c.o CMakeFiles/event.dir/log.c.o CMakeFiles/event.dir/signal.c.o CMakeFiles/event.dir/strlcpy.c.o CMakeFiles/event.dir/select.c.o CMakeFiles/event.dir/poll.c.o CMakeFiles/event.dir/kqueue.c.o CMakeFiles/event.dir/evthread_pthread.c.o CMakeFiles/event.dir/event_tagging.c.o CMakeFiles/event.dir/http.c.o CMakeFiles/event.dir/evdns.c.o CMakeFiles/event.dir/evrpc.c.o
/usr/bin/ranlib lib/libevent.a
[ 9%] Built target event
make: *** [all] Error 2
Do not report this issue to Homebrew/brew or Homebrew/core!
Please create pull requests instead of asking for help on Homebrew's GitHub,
Twitter or any other official channels.
getting the same make error. I searched on google but not found anything relevant.

Since you're trying to install a deprecated package that won't be translated to the M1 architecture, my recommendation is to use Rosetta to install it.
You can follow the steps here to setup a terminal running with Rosetta.
You'll know you're in a Rosetta terminal when you get i386 when running the arch command in your terminal.
Perform the installation steps there using homebrew. Please note the slightly different installation folder when installing with a Rosetta terminal vs native terminal.
The service should run using brew services start mysql#5.6.

Related

High version qemu-mipsel could not find libs automatically

System info
kernel:Linux ubuntu 5.4.0-121-generic #137~18.04.1-Ubuntu SMP Mon Jun 20 07:25:24 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Distributor ID: Ubuntu
Description: Ubuntu 18.04.6 LTS
Release: 18.04
Codename: bionic
Default version of qemu installed by apt will cause system error when using gdb-multiarch to debug mips executable files. So i'm trying to compile the source codes.
I've installed re2c, ninja and some packages, which are the dependency of qemu.
wget https://github.com/skvadrik/re2c/releases/download/3.0/re2c-3.0.tar.xz
tar -xvzf re2c-1.0.1.tar.gz
cd re2c-1.0.1/
./configure
make -j4
sudo make install
cd ..
git clone https://github.com/ninja-build/ninja.git
cd ninja
./configure.py --bootstrap
sudo cp ninja /usr/bin/
ninja --version
cd ..
sudo apt install build-essential zlib1g-dev pkg-config
sudo apt install libglib2.0-dev binutils-dev libboost-all-dev libssl-dev
sudo apt install libpixman-1-dev libfdt-dev libsdl2-dev
Then i'd like to build qemu statically and get executable like qemu-mipsel(which are static linked so i rename the files with -static suffix). But when i was trying to run any mips executable file, i got error below.
$ ./qemu-mipsel-static (mips_file_name)
qemu-mipsel-static: Could not open '/lib/ld.so.1': No such file or directory
I'm sure that the arch and endian is right. And i copied related lib files in /usr/mipsel-linux-gnu/lib to current directory and using option -L to specify the lib file path. I got the same result.
And i tried the version installed by apt, It can run smoothly.
Commands for installing qemu via apt are as followed.
sudo apt-get install qemu
sudo apt-get install qemu-user-static
sudo apt-get install qemu-system
sudo apt-get install uml-utilities
sudo apt-get install bridge-utils
However, as for the higher version of qemu compiled by source code, when i was tring commands below, it can run smoothly.
chroot . ./qemu-mipsel-static (mips file)
I wonder the reason and how to correctly run the file using ./ and chroot two ways. Thanks for your help!

TravisCI - Google Chrome stable cannot be authenticated

I'm trying to add TravisCI to my project, but I won't stop getting this error when triggering the builds:
WARNING: The following packages cannot be authenticated!
google-chrome-stable E: There were unauthenticated packages and -y was
used without --allow-unauthenticated apt-get.diagnostics apt-get
install failed The command "sudo -E apt-get -yq --no-install-suggests
--no-install-recommends $(travis_apt_get_options) install google-chrome-stable" failed and exited with 100 during .
I've searched for an answer and I found that adding chrome: stable in the addons section should fix it, but it's still failing. This is the .travis.yml file:
dist: trusty
sudo: false
language: node_js
node_js:
- "10"
addons:
chrome: stable
apt:
sources:
- google-chrome
packages:
- google-chrome-stable
cache:
directories:
- ./node_modules
install:
- cd project/projectName
- npm install
script:
- npm run test -- --no-watch --no-progress --browsers=ChromeHeadlessCI
- npm run e2e -- --protractor-config=e2e/protractor-ci.conf.js
And this is the full log:
Worker information
0.17s0.01s0.00s0.01s
system_info
Build system information
0.00s0.00s6.03s0.00s4.23s0.00s1.26s
docker_mtu_and_registry_mirrors
docker stop/waiting
resolvconf
resolvconf stop/waiting
Adding APT Sources
0.16s$ curl -sSL "https://build.travis-ci.com/files/gpg/google-chrome.asc" | sudo -E apt-key add -
OK
0.01s$ echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee -a ${TRAVIS_ROOT}/etc/apt/sources.list >/dev/null
7.82s$ travis_apt_get_update
Installing APT Packages
0.50s$ sudo -E apt-get -yq --no-install-suggests --no-install-recommends $(travis_apt_get_options) install google-chrome-stable
Reading package lists...
Building dependency tree...
Reading state information...
The following packages were automatically installed and are no longer required:
indicator-application libappindicator1 libappindicator3-1 libdbusmenu-glib4
libdbusmenu-gtk3-4 libdbusmenu-gtk4 libindicator3-7 libindicator7
Use 'sudo apt autoremove' to remove them.
Recommended packages:
libu2f-udev libvulkan1
The following packages will be upgraded:
google-chrome-stable
1 upgraded, 0 newly installed, 0 to remove and 303 not upgraded.
Need to get 75.8 MB of archives.
After this operation, 59.1 MB of additional disk space will be used.
WARNING: The following packages cannot be authenticated!
google-chrome-stable
E: There were unauthenticated packages and -y was used without --allow-unauthenticated
apt-get.diagnostics
apt-get install failed
The command "sudo -E apt-get -yq --no-install-suggests --no-install-recommends $(travis_apt_get_options) install google-chrome-stable" failed and exited with 100 during .
Your build has been stopped.
How could I fix this? Also, since the root folder (where the .travis.yml file is) isn't where the app is located (it is under root/project/projectName), I wrote - cd project/projectName before doing the -npm install, I don't know if thats the correct way of doing it, so I'd also like to check that.
Thanks!

how install OCR tesseract on opencv 3.1.0 on linux ubuntu 14.10?

I would like install correctly Opencv_contrib for Text_recognition. Have you a idea to the good process?
Before I install Opencv 3.1.0 and opencv_contrib, I install leptonia-1.73, protobuf, caffe, and after Tesseract. After I start to install Opencv 3.1.0 and opencv_contrib.
But I don't use Texte module
Process:
1. Install leptonia :
$ sudo apt-get install autoconf automake libtool
$ sudo apt-get install libpng12-dev
$ sudo apt-get install libjpeg62-dev
$ sudo apt-get install libtiff4-dev
$ sudo apt-get install zlib1g-dev
$ sudo apt-get install libicu-dev
$ sudo apt-get install libpango1.0-dev
$ sudo apt-get install libcairo2-dev
$ wget http://www.leptonica.org/source/leptonica-1.73.tar.gz
$ tar -zxvf leptonica-1.73.tar.gz
$ cd leptonica-1.73
$ ./autogen.sh
$ ./configure
$ make
$ sudo checkinstall
$ sudo ldconfig
2. Install protobuf
like "https:"//launchpad."net/ubuntu/trusty/"+package/protobuf-compiler"
3. Install Caffe
like "http:"//caffe."berkeleyvision."org"/install_apt"."html
4. Install Opencv 3.1.0 with Opencv_extra_module_path
$ cd ~/opencv
$ mkdir build
$ cd build
$ cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_C_EXAMPLES=OFF \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \
-D BUILD_EXAMPLES=ON ..
Warning message:
Warning message is : joboxlearning#joboxlearning-VirtualBox:~/OpenCV/workspace/text_recognition$ ./Text_recognition 2856985-origpic-28a761.jpg
./Text_recognition
Demo program of the Extremal Region Filter algorithm described in
Neumann L., Matas J.: Real-Time Scene Text Localization and Recognition, CVPR 2012
init done
opengl support available
OpenCV Error: Bad argument (Default classifier file not found!) in ERClassifierNM1, file /home/joboxlearning/OpenCV/opencv_contrib/modules/text/src/erfilter.cpp, line 1035
terminate called after throwing an instance of 'cv::Exception'
what(): /home/joboxlearning/OpenCV/opencv_contrib/modules/text/src/erfilter.cpp:1035: error: (-5) Default classifier file not found! in function ERClassifierNM1
Abandon (core dumped)
Check this Dockerfile (https://gist.github.com/joost/52d59321abe31884ab818b806c69426b) it shows all steps to install OpenCV 3.1 with Tesseract and Python bindings. You should be able to use all features like OCR and ERFilter.
To test them open python:
>>> import cv2
>>> cv2.__version__
'3.1.0'
>>> cv2.text # should return the module

Using GPU from a docker container?

I'm searching for a way to use the GPU from inside a docker container.
The container will execute arbitrary code so i don't want to use the privileged mode.
Any tips?
From previous research i understood that run -v and/or LXC cgroup was the way to go but i'm not sure how to pull that off exactly
Writing an updated answer since most of the already present answers are obsolete as of now.
Versions earlier than Docker 19.03 used to require nvidia-docker2 and the --runtime=nvidia flag.
Since Docker 19.03, you need to install nvidia-container-toolkit package and then use the --gpus all flag.
So, here are the basics,
Package Installation
Install the nvidia-container-toolkit package as per official documentation at Github.
For Redhat based OSes, execute the following set of commands:
$ distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
$ curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.repo | sudo tee /etc/yum.repos.d/nvidia-docker.repo
$ sudo yum install -y nvidia-container-toolkit
$ sudo systemctl restart docker
For Debian based OSes, execute the following set of commands:
# Add the package repositories
$ distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
$ curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
$ curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
$ sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit
$ sudo systemctl restart docker
Running the docker with GPU support
docker run --name my_all_gpu_container --gpus all -t nvidia/cuda
Please note, the flag --gpus all is used to assign all available gpus to the docker container.
To assign specific gpu to the docker container (in case of multiple GPUs available in your machine)
docker run --name my_first_gpu_container --gpus device=0 nvidia/cuda
Or
docker run --name my_first_gpu_container --gpus '"device=0"' nvidia/cuda
Regan's answer is great, but it's a bit out of date, since the correct way to do this is avoid the lxc execution context as Docker has dropped LXC as the default execution context as of docker 0.9.
Instead it's better to tell docker about the nvidia devices via the --device flag, and just use the native execution context rather than lxc.
Environment
These instructions were tested on the following environment:
Ubuntu 14.04
CUDA 6.5
AWS GPU instance.
Install nvidia driver and cuda on your host
See CUDA 6.5 on AWS GPU Instance Running Ubuntu 14.04 to get your host machine setup.
Install Docker
$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
$ sudo sh -c "echo deb https://get.docker.com/ubuntu docker main > /etc/apt/sources.list.d/docker.list"
$ sudo apt-get update && sudo apt-get install lxc-docker
Find your nvidia devices
ls -la /dev | grep nvidia
crw-rw-rw- 1 root root 195, 0 Oct 25 19:37 nvidia0
crw-rw-rw- 1 root root 195, 255 Oct 25 19:37 nvidiactl
crw-rw-rw- 1 root root 251, 0 Oct 25 19:37 nvidia-uvm
Run Docker container with nvidia driver pre-installed
I've created a docker image that has the cuda drivers pre-installed. The dockerfile is available on dockerhub if you want to know how this image was built.
You'll want to customize this command to match your nvidia devices. Here's what worked for me:
$ sudo docker run -ti --device /dev/nvidia0:/dev/nvidia0 --device /dev/nvidiactl:/dev/nvidiactl --device /dev/nvidia-uvm:/dev/nvidia-uvm tleyden5iwx/ubuntu-cuda /bin/bash
Verify CUDA is correctly installed
This should be run from inside the docker container you just launched.
Install CUDA samples:
$ cd /opt/nvidia_installers
$ ./cuda-samples-linux-6.5.14-18745345.run -noprompt -cudaprefix=/usr/local/cuda-6.5/
Build deviceQuery sample:
$ cd /usr/local/cuda/samples/1_Utilities/deviceQuery
$ make
$ ./deviceQuery
If everything worked, you should see the following output:
deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 6.5, CUDA Runtime Version = 6.5, NumDevs = 1, Device0 = GRID K520
Result = PASS
Ok i finally managed to do it without using the --privileged mode.
I'm running on ubuntu server 14.04 and i'm using the latest cuda (6.0.37 for linux 13.04 64 bits).
Preparation
Install nvidia driver and cuda on your host. (it can be a little tricky so i will suggest you follow this guide https://askubuntu.com/questions/451672/installing-and-testing-cuda-in-ubuntu-14-04)
ATTENTION : It's really important that you keep the files you used for the host cuda installation
Get the Docker Daemon to run using lxc
We need to run docker daemon using lxc driver to be able to modify the configuration and give the container access to the device.
One time utilization :
sudo service docker stop
sudo docker -d -e lxc
Permanent configuration
Modify your docker configuration file located in /etc/default/docker
Change the line DOCKER_OPTS by adding '-e lxc'
Here is my line after modification
DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4 -e lxc"
Then restart the daemon using
sudo service docker restart
How to check if the daemon effectively use lxc driver ?
docker info
The Execution Driver line should look like that :
Execution Driver: lxc-1.0.5
Build your image with the NVIDIA and CUDA driver.
Here is a basic Dockerfile to build a CUDA compatible image.
FROM ubuntu:14.04
MAINTAINER Regan <http://stackoverflow.com/questions/25185405/using-gpu-from-a-docker-container>
RUN apt-get update && apt-get install -y build-essential
RUN apt-get --purge remove -y nvidia*
ADD ./Downloads/nvidia_installers /tmp/nvidia > Get the install files you used to install CUDA and the NVIDIA drivers on your host
RUN /tmp/nvidia/NVIDIA-Linux-x86_64-331.62.run -s -N --no-kernel-module > Install the driver.
RUN rm -rf /tmp/selfgz7 > For some reason the driver installer left temp files when used during a docker build (i don't have any explanation why) and the CUDA installer will fail if there still there so we delete them.
RUN /tmp/nvidia/cuda-linux64-rel-6.0.37-18176142.run -noprompt > CUDA driver installer.
RUN /tmp/nvidia/cuda-samples-linux-6.0.37-18176142.run -noprompt -cudaprefix=/usr/local/cuda-6.0 > CUDA samples comment if you don't want them.
RUN export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64 > Add CUDA library into your PATH
RUN touch /etc/ld.so.conf.d/cuda.conf > Update the ld.so.conf.d directory
RUN rm -rf /temp/* > Delete installer files.
Run your image.
First you need to identify your the major number associated with your device.
Easiest way is to do the following command :
ls -la /dev | grep nvidia
If the result is blank, use launching one of the samples on the host should do the trick.
The result should look like that
As you can see there is a set of 2 numbers between the group and the date.
These 2 numbers are called major and minor numbers (wrote in that order) and design a device.
We will just use the major numbers for convenience.
Why do we activated lxc driver?
To use the lxc conf option that allow us to permit our container to access those devices.
The option is : (i recommend using * for the minor number cause it reduce the length of the run command)
--lxc-conf='lxc.cgroup.devices.allow = c [major number]:[minor number or *] rwm'
So if i want to launch a container (Supposing your image name is cuda).
docker run -ti --lxc-conf='lxc.cgroup.devices.allow = c 195:* rwm' --lxc-conf='lxc.cgroup.devices.allow = c 243:* rwm' cuda
We just released an experimental GitHub repository which should ease the process of using NVIDIA GPUs inside Docker containers.
Recent enhancements by NVIDIA have produced a much more robust way to do this.
Essentially they have found a way to avoid the need to install the CUDA/GPU driver inside the containers and have it match the host kernel module.
Instead, drivers are on the host and the containers don't need them.
It requires a modified docker-cli right now.
This is great, because now containers are much more portable.
A quick test on Ubuntu:
# Install nvidia-docker and nvidia-docker-plugin
wget -P /tmp https://github.com/NVIDIA/nvidia-docker/releases/download/v1.0.1/nvidia-docker_1.0.1-1_amd64.deb
sudo dpkg -i /tmp/nvidia-docker*.deb && rm /tmp/nvidia-docker*.deb
# Test nvidia-smi
nvidia-docker run --rm nvidia/cuda nvidia-smi
For more details see:
GPU-Enabled Docker Container
and: https://github.com/NVIDIA/nvidia-docker
Updated for cuda-8.0 on ubuntu 16.04
Install docker https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04
Build the following image that includes the nvidia drivers and the cuda toolkit
Dockerfile
FROM ubuntu:16.04
MAINTAINER Jonathan Kosgei <jonathan#saharacluster.com>
# A docker container with the Nvidia kernel module and CUDA drivers installed
ENV CUDA_RUN https://developer.nvidia.com/compute/cuda/8.0/prod/local_installers/cuda_8.0.44_linux-run
RUN apt-get update && apt-get install -q -y \
wget \
module-init-tools \
build-essential
RUN cd /opt && \
wget $CUDA_RUN && \
chmod +x cuda_8.0.44_linux-run && \
mkdir nvidia_installers && \
./cuda_8.0.44_linux-run -extract=`pwd`/nvidia_installers && \
cd nvidia_installers && \
./NVIDIA-Linux-x86_64-367.48.run -s -N --no-kernel-module
RUN cd /opt/nvidia_installers && \
./cuda-linux64-rel-8.0.44-21122537.run -noprompt
# Ensure the CUDA libs and binaries are in the correct environment variables
ENV LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-8.0/lib64
ENV PATH=$PATH:/usr/local/cuda-8.0/bin
RUN cd /opt/nvidia_installers &&\
./cuda-samples-linux-8.0.44-21122537.run -noprompt -cudaprefix=/usr/local/cuda-8.0 &&\
cd /usr/local/cuda/samples/1_Utilities/deviceQuery &&\
make
WORKDIR /usr/local/cuda/samples/1_Utilities/deviceQuery
Run your container
sudo docker run -ti --device /dev/nvidia0:/dev/nvidia0 --device /dev/nvidiactl:/dev/nvidiactl --device /dev/nvidia-uvm:/dev/nvidia-uvm <built-image> ./deviceQuery
You should see output similar to:
deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 8.0, CUDA Runtime Version = 8.0, NumDevs = 1, Device0 = GRID K520
Result = PASS
Goal:
My goal was to make a CUDA enabled docker image without using nvidia/cuda as base image. Because I have some custom jupyter image, and I want to base from that.
Prerequisite:
The host machine had nvidia driver, CUDA toolkit, and nvidia-container-toolkit already installed. Please refer to the official docs, and to Rohit's answer.
Test that nvidia driver and CUDA toolkit is installed correctly with: nvidia-smi on the host machine, which should display correct "Driver Version" and "CUDA Version" and shows GPUs info.
Test that nvidia-container-toolkit is installed correctly with: docker run --rm --gpus all nvidia/cuda:latest nvidia-smi
Dockerfile
I found what I assume to be the official Dockerfile for nvidia/cuda here I "flattened" it, appended the contents to my Dockerfile and tested it to be working nicely:
FROM sidazhou/scipy-notebook:latest
# FROM ubuntu:18.04
###########################################################################
# See https://gitlab.com/nvidia/container-images/cuda/-/blob/master/dist/10.1/ubuntu18.04-x86_64/base/Dockerfile
# See https://sarus.readthedocs.io/en/stable/user/custom-cuda-images.html
###########################################################################
USER root
###########################################################################
# base
RUN apt-get update && apt-get install -y --no-install-recommends \
gnupg2 curl ca-certificates && \
curl -fsSL https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub | apt-key add - && \
echo "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64 /" > /etc/apt/sources.list.d/cuda.list && \
echo "deb https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64 /" > /etc/apt/sources.list.d/nvidia-ml.list && \
apt-get purge --autoremove -y curl \
&& rm -rf /var/lib/apt/lists/*
ENV CUDA_VERSION 10.1.243
ENV CUDA_PKG_VERSION 10-1=$CUDA_VERSION-1
# For libraries in the cuda-compat-* package: https://docs.nvidia.com/cuda/eula/index.html#attachment-a
RUN apt-get update && apt-get install -y --no-install-recommends \
cuda-cudart-$CUDA_PKG_VERSION \
cuda-compat-10-1 \
&& ln -s cuda-10.1 /usr/local/cuda && \
rm -rf /var/lib/apt/lists/*
# Required for nvidia-docker v1
RUN echo "/usr/local/nvidia/lib" >> /etc/ld.so.conf.d/nvidia.conf && \
echo "/usr/local/nvidia/lib64" >> /etc/ld.so.conf.d/nvidia.conf
ENV PATH /usr/local/nvidia/bin:/usr/local/cuda/bin:${PATH}
ENV LD_LIBRARY_PATH /usr/local/nvidia/lib:/usr/local/nvidia/lib64
###########################################################################
#runtime next
ENV NCCL_VERSION 2.7.8
RUN apt-get update && apt-get install -y --no-install-recommends \
cuda-libraries-$CUDA_PKG_VERSION \
cuda-npp-$CUDA_PKG_VERSION \
cuda-nvtx-$CUDA_PKG_VERSION \
libcublas10=10.2.1.243-1 \
libnccl2=$NCCL_VERSION-1+cuda10.1 \
&& apt-mark hold libnccl2 \
&& rm -rf /var/lib/apt/lists/*
# apt from auto upgrading the cublas package. See https://gitlab.com/nvidia/container-images/cuda/-/issues/88
RUN apt-mark hold libcublas10
###########################################################################
#cudnn7 (not cudnn8) next
ENV CUDNN_VERSION 7.6.5.32
RUN apt-get update && apt-get install -y --no-install-recommends \
libcudnn7=$CUDNN_VERSION-1+cuda10.1 \
&& apt-mark hold libcudnn7 && \
rm -rf /var/lib/apt/lists/*
ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES all
ENV NVIDIA_REQUIRE_CUDA "cuda>=10.1"
###########################################################################
#docker build -t sidazhou/scipy-notebook-gpu:latest .
#docker run -itd -gpus all\
# -p 8888:8888 \
# -p 6006:6006 \
# --user root \
# -e NB_UID=$(id -u) \
# -e NB_GID=$(id -g) \
# -e GRANT_SUDO=yes \
# -v ~/workspace:/home/jovyan/work \
# --name sidazhou-jupyter-gpu \
# sidazhou/scipy-notebook-gpu:latest
#docker exec sidazhou-jupyter-gpu python -c "import tensorflow as tf; print(tf.config.experimental.list_physical_devices('GPU'))"
To use GPU from docker container, instead of using native Docker, use Nvidia-docker. To install Nvidia docker use following commands
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
curl -s -L https://nvidia.github.io/nvidia-docker/ubuntu16.04/amd64/nvidia-
docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update
sudo apt-get install -y nvidia-docker
sudo pkill -SIGHUP dockerd # Restart Docker Engine
sudo nvidia-docker run --rm nvidia/cuda nvidia-smi # finally run nvidia-smi in the same container
Use x11docker by mviereck:
https://github.com/mviereck/x11docker#hardware-acceleration says
Hardware acceleration
Hardware acceleration for OpenGL is possible with option -g, --gpu.
This will work out of the box in most cases with open source drivers on host. Otherwise have a look at wiki: feature dependencies.
Closed source NVIDIA drivers need some setup and support less x11docker X server options.
This script is really convenient as it handles all the configuration and setup. Running a docker image on X with gpu is as simple as
x11docker --gpu imagename
I would not recommend installing CUDA/cuDNN on the host if you can use docker. Since at least CUDA 8 it has been possible to "stand on the shoulders of giants" and use nvidia/cuda base images maintained by NVIDIA in their Docker Hub repo. Go for the newest and biggest one (with cuDNN if doing deep learning) if unsure which version to choose.
A starter CUDA container:
mkdir ~/cuda11
cd ~/cuda11
echo "FROM nvidia/cuda:11.0-cudnn8-devel-ubuntu18.04" > Dockerfile
echo "CMD [\"/bin/bash\"]" >> Dockerfile
docker build --tag mirekphd/cuda11 .
docker run --rm -it --gpus 1 mirekphd/cuda11 nvidia-smi
Sample output:
(if nvidia-smi is not found in the container, do not try install it there - it was already installed on thehost with NVIDIA GPU driver and should be made available from the host to the container system if docker has access to the GPU(s)):
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 450.57 Driver Version: 450.57 CUDA Version: 11.0 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 GeForce GTX 108... Off | 00000000:01:00.0 On | N/A |
| 0% 50C P8 17W / 280W | 409MiB / 11177MiB | 7% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
Prerequisites
Appropriate NVIDIA driver with the latest CUDA version support to be installed first on the host (download it from NVIDIA Driver Downloads and then mv driver-file.run driver-file.sh && chmod +x driver-file.sh && ./driver-file.sh). These are have been forward-compatible since CUDA 10.1.
GPU access enabled in docker by installing sudo apt get update && sudo apt get install nvidia-container-toolkit (and then restarting docker daemon using sudo systemctl restart docker).

Cannot build bitcoin

Get sauce from github, read instructions in doc/build-unix.txt. But make can not into compile!
[urs1412#noname bitcoin]$ cd src
[urs1412#noname src]$ make -f makefile.unix
g++ -c -O2 -pthread -Wall -Wextra -Wformat -Wformat-security \
-Wno-unused-parameter -g -DBOOST_SPIRIT_THREADSAFE \
-D_FILE_OFFSET_BITS=64 -I/home/urs1412/w/bitcoin/src \
-I/home/urs1412/w/bitcoin/src/obj -DUSE_UPNP=0 -DUSE_IPV6=1 \
-I/home/urs1412/w/bitcoin/src/leveldb/include \
-I/home/urs1412/w/bitcoin/src/leveldb/helpers \
-DHAVE_BUILD_INFO -fno-stack-protector \
-fstack-protector-all -Wstack-protector \
-D_FORTIFY_SOURCE=2 -MMD -MF obj/alert.d \
-o obj/alert.o alert.cpp \
alert.cpp:6:53: fatal error: boost/algorithm/string/classification.hpp:
No such file or directory
compilation terminated.
make: *** [obj/alert.o] Error 1
td;dr could not build bitcoin, dumping system info
[urs1412#noname src]$ uname -r
3.6.10-4.fc18.x86_64
[urs1412#noname src]$ git log -n 1
commit 77a1e12eed5fc66dce16584696f54988a8c2bf4e
Merge: fe15aa3 0565b71
Author: Gavin Andresen
Date: Wed Apr 24 08:48:06 2013 -0700
Merge pull request #2554 from fanquake/qt-pro-brew-patch
bitcoin-qt.pro Brew patch
I finally was able to build bitcoin-1.8 (not the git sources, although I believe these same steps will be applicable) on my CentOS VPS.
Here are the packages I had to install. Note that I had to build some of these.
As root:
yum install gcc-c++ make
install boost-devel
yum install db4-devel
yum install openssl-devel # but this didn't provide ec.h, hence the next steps
yum install rpm-build
rpm -U ~jcomeau/rpmbuild/RPMS/x86_64/openssl-devel-1.0.0e-1.x86_64.rpm
yum install lynx # for downloading some source packages
yum install python-devel # for building miniupnpc
rpm -i ~jcomeau/rpmbuild/RPMS/x86_64/libminiupnpc9-1.8.20130503-0.1.x86_64.rpm
rpm -i ~jcomeau/rpmbuild/RPMS/x86_64/libminiupnpc-devel-1.8.20130503-0.1.x86_64.rpm
Then as user, make BOOST_LIB_SUFFIX=-mt all test
If you need instructions on building the openssl-devel (the spec file was in the sources and mostly functional) and libminiupnpc-devel (I got the spec file from an OpenSUSE source RPM and adapted it) let me know.
I believe your immediate problem is you didn't install openssl-devel. But you will likely run into these other problems after that, if you don't do some of the steps I did.
Make sure that boost library for gcc is working correctly. Try a test "hello world" program with boost. You can find it in the directory: BOOST_BUILD_PATH/example/hello
Compile it with BOOST_BUILD_PATH/bin/b2 toolset=gcc
If it doesnt work then boost is not correctly installed.