Skip to content

Instantly share code, notes, and snippets.

View sonots's full-sized avatar
🤗

Naotoshi Seo sonots

🤗
View GitHub Profile
@sonots
sonots / retry.sh
Last active December 9, 2020 01:25
#!/usr/bin/env bash
PROGNAME=$(basename $0)
function usage() {
echo "Usage: $PROGNAME [-c MAX_RETRY] [-s INTERVAL_SEC] -- COMMAND" 1>&2
echo " Retry a command if failed" 1>&2
echo "" 1>&2
echo "Options:" 1>&2
echo " -h, --help Show this message" 1>&2

It occurred when I did not wait GPU process finishes.

#include <stdio.h>
#include <cuda_runtime.h>

__global__
void my_kernel(int val, int *A, int N)
{
 int i = threadIdx.x;
@sonots
sonots / fluentd_ruby2.1.1.md
Last active June 19, 2020 05:56
fluentd w/ ruby 2.1.1 の進捗ダメです。 #=> ロングランさせると安定しました

メモリ使用量が増え続ける

memory

最初の山: ruby 2.1.1 + fluentd v0.10.43 + cool.io v1.1.1 + msgpack v0.5.8 # ruby バージョンアップして、他の gem は安定稼働している本番と同じにした(同じ Gemfile.lock を使った)

2つ目の山: ruby 2.1.1 + fluentd v0.10.43 + cool.io v1.1.1 + msgpack v0.5.5 => 安定したかと一瞬思ったが "can't modify frozen String" 例外が出て何も処理できていなかっただけっぽい. v0.5.6 で修正された https://github.com/msgpack/msgpack-ruby/blob/master/ChangeLog

3つ目の山: ruby 2.1.1 + fluentd v0.10.43 + cool.io v1.1.1 + msgpack v0.5.6

$ brew install openblas
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local,
because macOS provides BLAS and LAPACK in the Accelerate framework.

For compilers to find this software you may need to set:
    LDFLAGS:  -L/usr/local/opt/openblas/lib
    CPPFLAGS: -I/usr/local/opt/openblas/include
For pkg-config to find this software you may need to set:
@sonots
sonots / gist:8058865
Last active October 11, 2019 15:59
WebRick should delete Content-Length for Chunked Transfer
@sonots
sonots / cudaMallocGetAlignment.cu
Last active September 2, 2019 02:39
invetigation on cudaMalloc alignment => aligned to at least **512** bytes
#include <sys/time.h>
#include <cuda_runtime.h>
#include <stdio.h>
void test(int size)
{
float *d1, *d2;
cudaMalloc(&d1, size);
cudaMalloc(&d2, size);
@sonots
sonots / gist:0270cb58f14e75362c9b
Last active June 17, 2019 09:30
rails で例外を rescue しなかったときに出るログだけ、別の logger に差し替えたい。error.log とか
controller で適当に例外おこして追って行く
From: /home/seo.naotoshi/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/actionpack-4.1.1/lib/action_controller/metal/rescue.rb @ line 31 ActionController::Rescue#process_action:
28: def process_action(*args)
29: super
30: rescue Exception => exception
=> 31: request.env['action_dispatch.show_detailed_exceptions'] ||= show_detailed_exceptions?
32: rescue_with_handler(exception) || raise(exception)
33: end

ためしてないけど、こんなかんじでできるのでは。

/etc/sysconfig/td-agent

export BUNDLE_BIN_PATH=/opt/td-agent/embedded/bin/bundle
export BUNDLE_GEMFILE=/etc/td-agent/Gemfile
export RUBYOPT=-rbundler/setup
@sonots
sonots / label1.md
Last active April 1, 2019 20:31
fluentd label and filter (1)
# fluent.conf
<source>
  type dummydata_producer
  tag dummy.data
  rate 500
  dummydata0 {\"type\":\"sample\",\"code\":50,\"format\":\"json string allowed\"}
  dummydata1 {\"message\":\"other format needed?\"}
  dummydata2 {\"comment\":\"N of dummydataN is number and not limited\"}
 @label @raw
@sonots
sonots / cudaStreamCallback.md
Last active November 2, 2018 14:12
Concurrency is lost by cudaStreamCallback?
$ nvcc simpleCallback.cu -O2 -o simpleCallback
$ nvprof -f -o simpleCallback.nvvp ./simpleCallback | grep elapsed
No callback: elapsed time = 1.534s
One callback: elapsed time = 1.498s
Two callback: elapsed time = 3.718s
Four callback: elapsed time = 5.194s

As increasing callbacks, it becomes slow...