Wednesday, June 14, 2017

Increase max heap size for Gradle test

To increase max heap size for Gradle test, add the following to your "build.gradle":

test {
    maxHeapSize = "4g"
}

Reference:
https://docs.gradle.org/3.4/dsl/org.gradle.api.tasks.testing.Test.html

Monday, June 12, 2017

How to change "launchctl limit maxfiles"

You can change it as follows:

$ launchctl limit maxfiles
maxfiles    256            unlimited    
$ sysctl kern.maxfiles
kern.maxfiles: 12288
$ sudo vi /Library/LaunchDaemons/limit.maxfiles.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
        "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>Label</key>
    <string>limit.maxfiles</string>
    <key>ProgramArguments</key>
    <array>
      <string>launchctl</string>
      <string>limit</string>
      <string>maxfiles</string>
      <string>65535</string>
      <string>65535</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>ServiceIPC</key>
    <false/>
  </dict>
</plist>

$ launchctl load -w /Library/LaunchDaemons/limit.maxfiles.plist
$ launchctl limit maxfiles
maxfiles    256            unlimited    
$ sudo launchctl load -w /Library/LaunchDaemons/limit.maxfiles.plist
$ launchctl limit maxfiles
maxfiles    65535          65535    
$ sysctl kern.maxfiles
kern.maxfiles: 65535
$

Note loading the configuration without "sudo" didn't work.

Reference:
https://blog.dekstroza.io/ulimit-shenanigans-on-osx-el-capitan/

Sunday, May 21, 2017

Using MySQL in R

You can use MySQL in R as follows:

> install.packages("RMySQL")
...
> library(RMySQL)
Loading required package: DBI
> connection = dbConnect(MySQL(), dbname='test')
> dbListTables(connection)
[1] "animal" "person"
>

Reference:
https://www.r-bloggers.com/accessing-mysql-through-r/

Library not loaded: /opt/X11/lib/libSM.6.dylib

When you install RMySQL, you might encounter the following error:

> install.packages("RMySQL")
...
  unable to load shared object '/Library/Frameworks/R.framework/Resources/modules//R_X11.so':
  dlopen(/Library/Frameworks/R.framework/Resources/modules//R_X11.so, 6): Library not loaded: /opt/X11/lib/libSM.6.dylib
  Referenced from: /Library/Frameworks/R.framework/Resources/modules//R_X11.so
  Reason: image not found
>

Installing XQuartz solved the problem for me.

Reference:
http://stackoverflow.com/questions/26489928/cant-load-x11-in-r-after-os-x-yosemite-upgrade

Friday, May 19, 2017

Library not loaded: /usr/local/opt/gcc/lib/gcc/5/libgomp.1.dylib

When you run "import xgboost", you might encounter the following error:
OSError: dlopen(/Users/izeye/anaconda/lib/python3.5/site-packages/xgboost/./lib/libxgboost.so, 6): Library not loaded: /usr/local/opt/gcc/lib/gcc/5/libgomp.1.dylib
  Referenced from: /Users/izeye/anaconda/lib/python3.5/site-packages/xgboost/./lib/libxgboost.so
  Reason: image not found

Adding a symbolic link as follows works for me:

ln -s /usr/local/opt/gcc\@5 /usr/local/opt/gcc

Monday, May 15, 2017

/bin/sh: clang-omp++: command not found

When you install XGBoost with "pip install xgboost", you might encounter the following error:

    /bin/sh: clang-omp++: command not found
    make: *** [build/learner.o] Error 127
    make: *** Waiting for unfinished jobs....

Doing as follows works for me:

brew install gcc@5
pip install xgboost

Reference:
https://github.com/dmlc/xgboost/issues/1501#issuecomment-292209578

ValueError: unknown locale: UTF-8

When you run a Python script, you might encounter the following error:

ValueError: unknown locale: UTF-8

Check your locale as follows:

Johnnyui-MacBook-Pro:~ izeye$ locale
LANG=
LC_COLLATE="C"
LC_CTYPE="UTF-8"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=
Johnnyui-MacBook-Pro:~ izeye$

Add the following to your ".bash_profile":

export LANG=ko_kr.UTF-8
export LC_ALL=ko_kr.UTF-8

Check your locale again as follows:

Johnnyui-MacBook-Pro:~ izeye$ locale
LANG="ko_kr.UTF-8"
LC_COLLATE="ko_kr.UTF-8"
LC_CTYPE="ko_kr.UTF-8"
LC_MESSAGES="ko_kr.UTF-8"
LC_MONETARY="ko_kr.UTF-8"
LC_NUMERIC="ko_kr.UTF-8"
LC_TIME="ko_kr.UTF-8"
LC_ALL="ko_kr.UTF-8"
Johnnyui-MacBook-Pro:~ izeye$

Now it's working.

Note "ko_kr" is for Korean, so use yours.