ubuntu18.4 にtensolrflow 動かすためにしたこと

cudaとかcudnnとか。gpuに関係しているものだろうか。

 apt-get install cuda-9.0

wget http://developer.download.nvidia.com/compute/redist/cudnn/v7.0.5/cudnn-9.0-linux-x64-v7.tgz
tar xzf cudnn-9.0-linux-x64-v7.tgz
cp -a cuda/lib64/* /usr/local/lib/
cp -a cuda/include/* /usr/local/include/
ldconfig

askubuntu.com

qiita.com

Install TensorFlow on Ubuntu  |  TensorFlow

d.hatena.ne.jp

Mysql で特定id毎の上位ランキングを出す

以下は結構便利。

SELECT *
FROM Table1 t1
WHERE 2 >= (
    SELECT COUNT(*)
    FROM Table1 t2
    WHERE t1.category = t2.category
    AND t2.point >= t1.point
)
ORDER BY category,point desc
select id, category, point, name
from 
(
   select *,
      @rank := if (@category = category, @rank + 1, 1) as rank,
      @category := category as dummy_field
  from Table1, (select @rank := 0, @category := 0) as dummy_table
  order by category, point desc
) as t
where t.rank <= 2
order by category, point desc

teratail.com

models の CharField に regex の判定を追加

alphanumeric の RegexValidator で追加。

alphanumeric = RegexValidator(r'^[0-9a-zA-Z]*$', 'Only alphanumeric characters are allowed.')

name = models.CharField(max_length=50, blank=True, null=True, validators=[alphanumeric])
email = models.EmailField(max_length=50, unique=True, validators=[alphanumeric])

stackoverflow.com

Django の models に対応したテーブルを MySQL から grep する方法

以下のコマンドで、取り出す。

mysql -uroot -N information_schema -e "select table_name from tables where table_schema = 'tablename' and table_name like 'prefix_%'" > table.txt