Building OpenCog is a moving target. As of 8th of May 2018, these instructions work on Ubuntu 18.04 LTS.
- Install VirtualBox and Vagrant(the method depends on your OS; In Mac OS High Sierra I use Homebrew by calling brew install vagrant)
- Init with Ubuntu 18.04 LTS: vagrant init bento/ubuntu-18.04
- vagrant up
- vagrant ssh
- cd /
- sudo dd if=/dev/zero of=swapfile bs=1M count=8000
- sudo chmod 600 swapfile
- sudo mkswap swapfile
- sudo swapon swapfile
- sudo vim etc/fstab
/swapfile none swap sw 0 0
- check that the swapfile was actually added: swapon --show
You may also want to add more storage to your Virtual Machine (depends on your VirtualBox environment):
- vagrant halt
- Go to the directory where you have your Virtual Box VMs (e.g. in Mac cd ~/VirtualBox VMs/some_id)
- VBoxManage clonehd ubuntu_something.vmdk ubuntu_something.vdi --format VDI
- VBoxManage ubuntu_something.vdi --resize 51200 (50 GB)
- Go to VirtualBox, unmount and delete the old .vmdk and mount the newly created .vdi.
-
sudo apt-get install gcc g++ make cmake libboost-all-dev cython python-nose python3-nose python-pytest python3-pytest postgresql postgresql-contrib postgresql-client guile-2.2-dev libtbb-dev libgearman-dev libpq-dev python-pip libblas-dev liblapack-dev uuid-dev doxygen libiberty-dev binutils-dev valgrind postgresql postgresql-client postgresql-contrib libpq-dev liblogging-stdlog0 liblogger-syslog-perl libzmq3-dev libprotobuf-dev libgtk-3-dev default-jdk python-cffi libffi-dev irssi irssi-scripts ca-certificates libcrypt-blowfish-perl libcrypt-dh-perl libcrypt-openssl-bignum-perl libmath-bigint-gmp-perl rlwrap
-
Read what apt-get says, if it tells to update then run
sudo apt-get update
and re-run step 1. -
sudo pip install -U setuptools
-
sudo easy_install cython nose
-
sudo ln -s /usr/share/i18n/SUPPORTED /var/lib/locales/supported.d/all
-
sudo locale-gen
-
Get Octool by following the guide here: https://github.com/opencog/ocpkg
-
./octool -rdospicamgvbe -l default -l java
- Check where your link-grammar exists (most likely in /usr/local/lib/python3.6/site-packages/link-grammar)
- Add the following to your ~/.bash_profile
export PYTHONPATH=$PYTHONPATH:/usr/local/share/moses/python/:/usr//local/lib/python3.5/dist-packages/:/usr/local/lib/python3.5/site-packages/:/usr//local/lib/python3.6/dist-packages/:/usr/local/lib/python3.6/site-packages/link-grammar/
- source ~/.bash_profile
NOTE: You need to check where atomspace actually is. You can do it by running find /usr |grep opencog |grep python
I use the following config at the end of /etc/postgresql/10/main/postgresql.conf:
shared_buffers = 256MB
work_mem = 32MB
effective_cache_size = 512MB
fsync = off
synchronous_commit = off
ssl = off
autovacuum = on
track_counts = on
# If you have an SSD drive add the following:
seq_page_cost = 0.1
random_page_cost = 0.15
effective_io_concurrency = 5
- sudo -u postgres psql template1
- ALTER USER postgres with encrypted password 'password';
- CREATE ROLE vagrant WITH SUPERUSER;
- ALTER ROLE vagrant WITH LOGIN;
- \q
- sudo vim /etc/postgresql/10/main/postgresql.conf
listen_address = '*'
- sudo vim /etc/sysctl.conf
- Add the following:
kernel.shmmax = 6440100100
- sudo vim /etc/postgresql/10/main/pg_hba.conf
replace peer with md5: local all postgres md5
local all all md5 host all all 0.0.0.0/0 md5
- sudo /etc/init.d/postgresql restart
- createuser -U postgres -d -e -E -l -P -r -s opencog_tester (set password cheese)
- createuser -U postgres -d -e -E -l -P -r -s opencog_user (set password cheese)
- sudo -u postgres createdb mycogdata
- sudo -u postgres createdb opencog_test
- GRANT ALL privileges ON DATABASE mycogdata to opencog_user;
- GRANT ALL privileges ON DATABASE opencog_test to opencog_tester;
- git clone https://github.com/opencog/atomspace.git
- cd atomspace
- cat opencog/persist/sql/multi-driver/atom.sql | psql mycogdata -U opencog_user -W -h localhost
- cat opencog/persist/sql/multi-driver/atom.sql | psql opencog_test -U opencog_tester -W -h localhost
- psql mycogdata -U opencog_user
- INSERT INTO TypeCodes (type, typename) VALUES (97, 'SemanticRelationNode');
- \q
- psql opencog_test -U opencog_tester
- INSERT INTO TypeCodes (type, typename) VALUES (97, 'SemanticRelationNode');
Both should display:
INSERT 0 1
NOTE: Also check that all tables in both databases are owned by their intended users by using \l
- cd opencog
- mkdir build
- cd build
- cmake ..
- make
- make test
- sudo make install
- git clone https://github.com/opencog/relex
- cd relex
- install-scripts/install-ubuntu-dependencies.sh
- Add the following to ~/.guile
(add-to-load-path "/usr/local/share/opencog/scm")
(add-to-load-path ".")
(use-modules (ice-9 readline))
(activate-readline)
(use-modules (opencog))
- Open another terminal window and log in:
vagrant ssh
- cd relex
- bash opencog_server.sh
- Go back to your original window and go to opencog build directory:
cd ~/opencog/build
guile -l ../opencog/nlp/chatbot/run-chatbot.scm
- You can post a question using guile, e.g.:
(process-query "luser" "Are you a bot?")
- For more examples see: https://github.com/opencog/opencog/tree/master/opencog/nlp/chatbot