Caffe'yi derlemek/yapılandırmak istiyorum, böylece yapay bir sinir ağı ile eğitim aldığımda eğitim çok iş parçacıklı (yalnızca CPU, GPU yok). Caffe ile multithreading nasıl etkinleştirilir? Ubuntu 14.04 LTS x64'te Caffe kullanıyorum.Caffe ile çoklu okuma nasıl etkinleştirilir?
cevap
Bir yol, varsayılan ATLAS yerine OpenBLAS kullanmaktır.
sudo apt-get install -y libopenblas-dev
-
Caffe derleme önce Bunu yapmak için,
- tarafından
BLAS := atlas
değiştirin.
Makefile.config
düzenlemek Caffe 4 çekirdek kullanmasına neden olacaktır
export OPENBLAS_NUM_THREADS=4
çalışan, Caffe derleme sonra
BLAS := open
ilgilenen varsa, burada yeni bir Ubuntu 14.04 LTS x64 veya Ubuntu 14.10 x64 üzerinde Caffe yüklemek için komut dosyası ve pycaffe olduğunu. Sadece CPU, çok iş parçacıklı Caffe. Muhtemelen geliştirilebilir, ama artık benim için yeterince iyi:
https://github.com/Franck-Dernoncourt/caffe_demos/tree/master/caffe_installation:
# This script installs Caffe and pycaffe on Ubuntu 14.04 x64 or 14.10 x64. CPU only, multi-threaded Caffe.
# Usage:
# 0. Set up here how many cores you want to use during the installation:
# By default Caffe will use all these cores.
NUMBER_OF_CORES=4
# 1. Execute this script, e.g. "bash compile_caffe_ubuntu_14.04.sh" (~30 to 60 minutes on a new Ubuntu).
# 2. Open a new shell (or run "source ~/.bash_profile"). You're done. You can try
# running "import caffe" from the Python interpreter to test.
#http://caffe.berkeleyvision.org/install_apt.html : (general install info: http://caffe.berkeleyvision.org/installation.html)
cd
sudo apt-get update
#sudo apt-get upgrade -y # If you are OK getting prompted
sudo DEBIAN_FRONTEND=noninteractive apt-get upgrade -y -q -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" # If you are OK with all defaults
sudo apt-get install -y libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev
sudo apt-get install -y --no-install-recommends libboost-all-dev
sudo apt-get install -y libatlas-base-dev
sudo apt-get install -y python-dev
sudo apt-get install -y python-pip git
# For Ubuntu 14.04
sudo apt-get install -y libgflags-dev libgoogle-glog-dev liblmdb-dev protobuf-compiler
# LMDB
# https://github.com/BVLC/caffe/issues/2729: Temporarily broken link to the LMDB repository #2729
#git clone https://gitorious.org/mdb/mdb.git
#cd mdb/libraries/liblmdb
#make && make install
git clone https://github.com/LMDB/lmdb.git
cd lmdb/libraries/liblmdb
sudo make
sudo make install
# More pre-requisites
sudo apt-get install -y cmake unzip doxygen
sudo apt-get install -y protobuf-compiler
sudo apt-get install -y libffi-dev python-dev build-essential
sudo pip install lmdb
sudo pip install numpy
sudo apt-get install -y python-numpy
sudo apt-get install -y gfortran # required by scipy
sudo pip install scipy # required by scikit-image
sudo apt-get install -y python-scipy # in case pip failed
sudo apt-get install -y python-nose
sudo pip install scikit-image # to fix https://github.com/BVLC/caffe/issues/50
# Get caffe (http://caffe.berkeleyvision.org/installation.html#compilation)
cd
mkdir caffe
cd caffe
wget https://github.com/BVLC/caffe/archive/master.zip
unzip -o master.zip
cd caffe-master
# Prepare Python binding (pycaffe)
cd python
for req in $(cat requirements.txt); do sudo pip install $req; done
echo "export PYTHONPATH=$(pwd):$PYTHONPATH " >> ~/.bash_profile # to be able to call "import caffe" from Python after reboot
source ~/.bash_profile # Update shell
cd ..
# Compile caffe and pycaffe
cp Makefile.config.example Makefile.config
sed -i '8s/.*/CPU_ONLY := 1/' Makefile.config # Line 8: CPU only
sudo apt-get install -y libopenblas-dev
sed -i '33s/.*/BLAS := open/' Makefile.config # Line 33: to use OpenBLAS
# Note that if one day the Makefile.config changes and these line numbers change, we're screwed
# Maybe it would be best to simply append those changes at the end of Makefile.config
echo "export OPENBLAS_NUM_THREADS=($NUMBER_OF_CORES)" >> ~/.bash_profile
mkdir build
cd build
cmake ..
cd ..
make all -j$NUMBER_OF_CORES # 4 is the number of parallel threads for compilation: typically equal to number of physical cores
make pycaffe -j$NUMBER_OF_CORES
make test
make runtest
#make matcaffe
make distribute
# Bonus for other work with pycaffe
sudo pip install pydot
sudo apt-get install -y graphviz
sudo pip install scikit-learn
# At the end, you need to run "source ~/.bash_profile" manually or start a new shell to be able to do 'python import caffe',
# because one cannot source in a bash script. (http://stackoverflow.com/questions/16011245/source-files-in-a-bash-script)
Ben GitHub'dan bu senaryoyu yerleştirdik.
Caffe oluştururken, OPENMP'yi desteklemek için -fopenmp'i CXXFLAGS ve LINKFLAGS'a eklemeniz gerekir. Makefil.config dosyasında OPENMP adlı bir işaretiniz varsa, bunu 1 olarak ayarlayabilirsiniz. OPENBLAS veya Intel MKL BLAS kütüphanesini kullanabilirsiniz. OPENBLAS'ı kurarken, OPENMP'yi destekleyecek şekilde USE_OPENMP = 1 bayrağını ayarlamanız gerekir. Caffe oluşturduktan sonra, lütfen çalışma zamanı boyunca kullanmak istediğiniz iş parçacığı sayısını OMP_NUM_THREADS = n ayarlayarak dışa aktarın. N burada istediğiniz iş parçacığı sayısıdır. İşte Caffe'de çok iş parçacığı ile ilgili iyi bir tartışma: https://github.com/BVLC/caffe/pull/439
bu master dalında mı? uygulandığı çekme talebine bağlantı kurabilir misiniz? – Shai
Uygulandığı yerde neyi kastediyorsunuz? CXXFLAGS ve LINKFLAGS, Github'dan klonladığınız/indirdiğiniz her caffe kodunun Makefile.config dosyasındadır. – dipendra009
"USE_OPENMP" makrosu kodunun kullanıldığı yerde bulamadım, makefile yoluyla * tanımlı olduğunu biliyorum, ancak kodda bu makronun nerede olduğunu sorgulamadım. – Shai
- 1. Caffe ile çoklu etiket sınıflandırması
- 2. Caffe Çoklu Giriş Görüntüleri
- 3. Cocos2d'de çoklu dokunma nasıl etkinleştirilir?
- 4. Caffe
- 5. Okhttp authenticator çoklu okuma
- 6. iPad - Bu çoklu görev hareketleri nasıl etkinleştirilir?
- 7. LLVM'de Çoklu Okuma
- 8. Caffe sigint
- 9. Bir dosyadan okuma, çoklu ayırıcı
- 10. Caffe ile pycaffe arasındaki çözücü parametrelerini değiştirme
- 11. php html'de IE'de çoklu görüntü dosyası seçimi nasıl etkinleştirilir?
- 12. Çoklu Konu ile tek bir dosyayı okuma: hızlandırmalı mı?
- 13. CefSharp ile Adobe Flash nasıl etkinleştirilir?
- 14. php.ini'den mbstring nasıl etkinleştirilir?
- 15. NFC ayarı nasıl etkinleştirilir
- 16. Debian'da AUFS nasıl etkinleştirilir?
- 17. Ekstralarda buton nasıl etkinleştirilir?
- 18. Javascript küçültme nasıl etkinleştirilir?
- 19. Xcode'ta indeksleme nasıl etkinleştirilir?
- 20. Firefox'ta YSlow nasıl etkinleştirilir?
- 21. caffe matlab kullanarak bir filtre nasıl ayarlanır?
- 22. Tensorflow modelini Caffe modeline dönüştürün
- 23. Caffe | solver.prototxt değerler ayarlama stratejisi
- 24. GWT'nin İskelesi'nde HTTPS nasıl etkinleştirilir?
- 25. Yüklemeden sonra mod_wsgi nasıl etkinleştirilir
- 26. Otomatik izleme angularJ nasıl etkinleştirilir?
- 27. Qlabel'de kenar yumuşatma nasıl etkinleştirilir?
- 28. İlkbahar-önyüklemede TaskScheduler nasıl etkinleştirilir?
- 29. Çift kesikli kenarlık nasıl etkinleştirilir?
- 30. Espresso Test Kaydı nasıl etkinleştirilir
Varsayılan olarak libopenblas-dev kurulduğunda kaç çekirdek kullanılacaktır? – mrgloom
@mrgloom, ilk testimde sadece bir tane kullanıyordu – PlagTag
Script iyi çalışıyor, ancak Caffe'nin ana dalını kullanıyorum ve 'sed -i' 33s /.*/ BLAS: = open/'Makefile.config' , 'sed -i' olmalı 46s /.*/ BLAS: = open/'Makefile.config'. – cagatayodabasi