お知らせ

現在サイトのリニューアル作業中のため、全体的にページの表示が乱れています。

タイトルの通りさくらのレンタルサーバーにTiny Tiny RSSを構築する話。いつの間にかDockerコンテナにされてたが本体は単純なPHPのままなのできちんと設定してやるとDocker環境がなくとも動く。

確認環境

Env Ver
Tiny Tiny RSS dc25a9cf6816b756cb38490eab93f02589c44a10

手順

以降Tiny Tiny RSSをTTRSS表記とする。

  1. さくらのコンパネからTTRSSで利用するDBを作る
  2. 以下のセットアップスクリプトを適宜書き換えて実行する
git clone https://git.tt-rss.org/fox/tt-rss.git

cd tt-rss/

cat <<'EOF' | > config.php
<?php
# This file can be used to customize global defaults if environment method is not available (i.e. no Docker).
#
# Use the following syntax to override defaults (options are declared in classes/config.php, prefixed by TTRSS_):
#
# putenv('TTRSS_SELF_URL_PATH=http://example.com/tt-rss');
#
# Plugin-required constants also go here, using define():
#
# define('LEGACY_CONSTANT', 'value');
#
# See this page for more information: https://tt-rss.org/wiki/GlobalConfig

putenv('TTRSS_PHP_EXECUTABLE=/usr/local/bin/php');

# Sets admin user access level to this value.
# Valid values:
# -2 - forbidden to login
# -1 - readonly
#  0 - default user
# 10 - admin
putenv('ADMIN_USER_ACCESS_LEVEL=10');

# Database
putenv('TTRSS_DB_TYPE=mysql');
putenv('TTRSS_DB_HOST=database.example.com');
putenv('TTRSS_DB_PORT=3306');
putenv('TTRSS_DB_USER=hoge');
putenv('TTRSS_DB_NAME=piyo');
putenv('TTRSS_DB_PASS=fuga');

# You will likely need to set this to the correct value, see README.md
# for more information.
putenv('TTRSS_SELF_URL_PATH=https://example.com/');
EOF

php update.php --update-schema
  1. TTRSSを設置したURLにアクセスする
  2. ID: admin, PW: password でログインする
  3. ログインパスワードを変更する
  4. 適当にフィードを登録する
  5. php update.php --feeds を流す
  6. TTRSSの画面でフィードが取得できることを確認する
  7. cronに以下のコマンドを適当に登録する
    • /usr/local/bin/php /home/<USER>/www/tt-rss/update.php --feeds --quiet 1> /dev/null

トラブルシューティング

TTRSS画面を開くとエラーが出る:Exception while creating PDO object:could not find driver

.envに設定を書いても読み込まれないのでconfig.phpに書く

TTRSS画面上にRSSの取得失敗エラーが出る:Update process failed with exit code: 127 ()

以下のコマンドを実行したときにエラーが出る筈なので、それを見て対処する

php update.php --force-update
php update.php --feeds

phpのパスが見つからないと言われた場合はconfig.phpputenv('TTRSS_PHP_EXECUTABLE=<PHP_PATH>');を追加して、phpのパスを設定すれば直る

フィードを追加しても更新されない

勝手に更新されることはないのでCRONが走るのを待つか以下のコマンドを流す

php update.php --feeds

Androidアプリが欲しい

Google Playにはなく、公式サイトからapkを落としてくる必要がある。
昔は有料だったが今は地味に無料化されている。

https://gitlab.tt-rss.org/tt-rss/tt-rss-android/-/releases

参考情報

2023-05-04現在、無料枠では利用できない可能性があります。

Google ColaboratoryでStable Diffusionを動かす場合、無料と有料でどの程度変わるのか試してみたのでその結果。ざっくり4倍ほど変わるのかなというのが体感です。

レンダリング条件

今回は以下の設定で回した結果を比較します。

WebUIの設定スクショ

ベースとなるNotebookは以下を使っています。

https://gist.github.com/Lycolia/cb432ad1b1ce083482b5487c131b5d12/80a059931c538b10d55cf9fcbf82220f24e64653

設定値は以下です。ほぼデフォです。

設定
Propmpt (illustration:1.0), masterpiece, best quality, 1girl, solo, happy, smile, theater, (perspective:1.3), from below, (looking away:1.2), (from side:1.0), {{shot_hair}}, smile, bangs, shaggy, (brown hair:1.1), swept_bangs, thick_eyebrows, skin_fang, closed mouth, {{purple eyes}}, gray {{jacket}}, white shirt, glasses, {{small breasts}},
Negative Prompt nsfw, (worst quality, low quality:1.4), (depth of field, blurry, bokeh:1.5), (greyscale, monochrome:1.0), multiple views, text, title, logo, signature, (tooth, lip, nose, 3d, realistic:1.0), dutch angle,(cropped:1.4), text, title, signature, logo, (loli:1.2), school satchel, pink, school bag, school uniform, from behind
Model AOM3A1B
VAE orangemix.vae.pt
Sampleing method Euler a
Sampleing steps 20
Width 512px
Height 512px
Batch count 1
Batch size 1
CFG Scale 7
Seed -1

比較結果

レンダリング時間はTotal progressの時間を書いてます。

\ Colab無料枠 Colab Pro
GPUクラス 標準 プレミアム
メモリ 標準 ハイメモリ
GPU Tesla T4 A100
システムRAM 12.7 GB 83.5 GB
GPU RAM 15.0 GB 40.0GB
ディスク 166.8 GB 166.8 GB
レンダリング時間 8秒 2秒

セットアップ時間はどちらも5分ほど。

スペック情報参考

無料枠

Golab Proで標準GPUにしても同じです。

Tue Apr 11 12:50:30 2023
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 525.85.12    Driver Version: 525.85.12    CUDA Version: 12.0     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  Tesla T4            Off  | 00000000:00:04.0 Off |                    0 |
| N/A   70C    P8    33W /  70W |      0MiB / 15360MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Wed_Sep_21_10:33:58_PDT_2022
Cuda compilation tools, release 11.8, V11.8.89
Build cuda_11.8.r11.8/compiler.31833905_0
              total        used        free      shared  buff/cache   available
Mem:           12Gi       628Mi       7.4Gi       5.0Mi       4.6Gi        11Gi
Swap:            0B          0B          0B

Colab Pro

Pay As You Goで有料枠買ってもGPUは同じです。

Tue Apr 11 12:55:03 2023
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 525.85.12    Driver Version: 525.85.12    CUDA Version: 12.0     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA A100-SXM...  Off  | 00000000:00:04.0 Off |                    0 |
| N/A   39C    P0    46W / 400W |      0MiB / 40960MiB |      0%      Default |
|                               |                      |             Disabled |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Wed_Sep_21_10:33:58_PDT_2022
Cuda compilation tools, release 11.8, V11.8.89
Build cuda_11.8.r11.8/compiler.31833905_0
              total        used        free      shared  buff/cache   available
Mem:           83Gi       756Mi        79Gi       1.0Mi       3.3Gi        82Gi
Swap:            0B          0B          0B

おまけの成果物

そこそこちゃんとした絵は頑張ってプロンプト練ったり、ひたすら回したり、i2iを繰り返したりしないと、やっぱ出てこないですね。まぁモデルによっては楽に出せたりしますが、権利関係が怪しかったりするのでここには出せないです…w

あとがき

時間帯によってUIが異様に重くなることがあり、GPUの処理速度も時間帯によっては1秒未満で終わることがあった気もするので、この不安定さはクラウドユースの欠点だなぁと思いました。とは言え、GPUを買うことに比べれば手軽に利用できるのは、やはりメリットかなと思います。

よく使う人はグラボ買ったほうがストレスとかから開放される可能性はあるかもしれません。私はRTX2060なのでどう転んでもColabの方がマシなのが悲しいところ…。4070Ti買うか地味に迷いますね。

確認環境

Windows

あらかじめgpgのパスをPATHに通しておくと良い
参考値:C:\Program Files (x86)\GnuPG\bin

Env Ver
Windows 10 Pro Build 19042.804
git 2.30.0.windows.1
VSCode 1.53.2
Kleopatra Gpg4win-3.1.15

Linux

Windows側からVSCodeのRemote - SSHで接続

Env Ver
Ubuntu Desktop 20.04.2
git 2.25.1
gpg 2.2.19

手順

Windows

  1. Kleopatoraを起動
  2. ファイル> New Pair Key
  3. 個人用のOpenPGP鍵ペアを生成
    1. 期限なし、パスフレーズは適当に
  4. Exportから -----BEGIN PGP PUBLIC KEY BLOCK----- の中身を全部GitHubの GPG keys/ Add new に貼り付ける
  5. 追加後にでてきた Key IDgit config --global user.signingkey KeyID として cmd に流す
  6. 以下を流す(gpg.program はなくても動くが、あったほうが問題が起きない)
    ```bat
    git config --global commit.gpgsign true
    git config --global gpg.program "C:\Program Files (x86)\GnuPG\bin\gpg.exe"
    ```
  7. 管理者権限で cmd を起動し次のシンボリックリンクを作成
    1. mklink /D %USERPROFILE%.gnupg %AppData%\GnuPG
  8. VSCodeで適当なリポジトリを作成
  9. なんか適当にコミットする
  10. GitHubに投げる
  11. GitHubのコミット履歴にverified signatureがついてたら成功

Linux

  1. Windows側のKleopatoraから公開鍵と秘密鍵をエクスポートして持ってくる
  2. gpg --import FooBarpublic.asc で公開鍵をインポート
  3. gpg -k でインポートされていることを確認し、下記XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX相当の部分をコピペ
pub rsa3072 2021-01-17 [SC]
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
uid [ 不明 ] Foo Bar <foobar@example.com>
sub rsa3072 2021-01-17 [E]
  1. gpg --edit-key XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  2. trust
  3. 5を選ぶ
  4. quit
  5. gpg -kで信用度が[ 究極 ]になっていることを確認
  6. gpg --import FooBarSECRET.ascで秘密鍵をインポート
    1. SSHで繋いでいる時でタイムアウトする場合、GUIプロンプトからの入力になっている可能性があるので、どうにかして入力
    2. XRDP経由ならpkill gnome-sessionを叩くと入れる
  7. Windowsの時と同様に次のコマンドを流す
    1. git config --global user.signingkey KeyID
    2. git config --global commit.gpgsign true
  8. VSCodeで適当なリポジトリを作成
  9. 何か適当にコミットする
    1. コミットがコケたらXRDPから入力する
  10. GitHubに投げる
  11. GitHubのコミット履歴にverified signatureがついてたら成功
CLIからやる場合でパスフレーズを何度も打ちたくないケース

以下の手順が参考になる

WSL2のUbuntuでGPGキーのパスフレーズを記憶させる

トラブルシュート

Key IDを確認したい

以下のコマンドで確認可能

gpg --list-signatures

GPGキーを消したい

GPGキーの消し方