<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Lucas Eduardo</title>
    <description>The latest articles on Forem by Lucas Eduardo (@lucasew).</description>
    <link>https://forem.com/lucasew</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F361246%2F165daf1e-3cb4-4818-ac4b-2b858a131274.jpeg</url>
      <title>Forem: Lucas Eduardo</title>
      <link>https://forem.com/lucasew</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/lucasew"/>
    <language>en</language>
    <item>
      <title>How I messed up my systemd logs in NixOS and how I fixed it.</title>
      <dc:creator>Lucas Eduardo</dc:creator>
      <pubDate>Mon, 07 Aug 2023 16:21:00 +0000</pubDate>
      <link>https://forem.com/lucasew/how-i-messed-up-my-systemd-logs-in-nixos-and-how-i-fixed-it-53bn</link>
      <guid>https://forem.com/lucasew/how-i-messed-up-my-systemd-logs-in-nixos-and-how-i-fixed-it-53bn</guid>
      <description>&lt;p&gt;NixOS is an amazing distro, like, imagine configuring all your system stuff, containers, services, programs, development environments and so on using a consistent language. This is not the future but actually the present.&lt;/p&gt;

&lt;p&gt;Even though NixOS modules can do validation of inputs and scenarios such as not allowing you to have both pipewire and pulseaudio in the same system, because it's known that it will conflict with each other, there are stuff that modules can't predict, and at the end of the day modules are made by humans and humans do make mistakes even though there is a lot of code review happening on nixpkgs.&lt;/p&gt;

&lt;p&gt;This case is very unlikely to be treated by a module because it's more like a runtime issue.&lt;/p&gt;

&lt;p&gt;Systemd-journald grants access to users to view their service logs using ACLs, that are basically an extension to what chmod does. Root and the systemd-logs have write access to the logs and the final user only has the privilege to read them using a special annotation. The problem is that my zfs filesystem wasn't allowing this annotation to be saved because zfs doesn't support saving these ACLs by default. For it to save you have to set the &lt;code&gt;acltype&lt;/code&gt; attribute to &lt;code&gt;posixacl&lt;/code&gt; using &lt;code&gt;zfs set&lt;/code&gt;. I did know about this when I built the partition scheme for this system but I missed a small little thing: It was mounting that dataset on the wrong location: &lt;code&gt;/var/journal&lt;/code&gt; instead of &lt;code&gt;/var/log/journal&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;To fix this, first I stopped the journal using &lt;code&gt;systemctl stop systemd-journald&lt;/code&gt; so it would not try to write to that location. Second, I moved &lt;code&gt;/var/log/journal&lt;/code&gt; to &lt;code&gt;/var/log/journal.old&lt;/code&gt; then created an empty folder on that location so I can remount that dataset that was mounted on the wrong place to &lt;code&gt;/var/log/journal&lt;/code&gt;. After that I copied using rsync from &lt;code&gt;/var/log/journal.old&lt;/code&gt; to &lt;code&gt;/var/log/journal&lt;/code&gt;, fixed the ACLs using &lt;code&gt;sudo setfacl u:lucasew:r 97e3b5a7928145bdb0d45bc645b5c20e/user-1000*&lt;/code&gt; (you will have to change it to your own user and user id) and then tested running &lt;code&gt;journalctl --user -r&lt;/code&gt;. Stuff then appeared nicely so it's fixed. Finally I ran &lt;code&gt;systemctl start systemd-journald&lt;/code&gt; to start the journal service again and &lt;a href="https://github.com/lucasew/nixcfg/commit/17e75862c4e4eeaabfb7e717fed8cd0e19342e74"&gt;changed in my &lt;code&gt;hardware-configuration.nix&lt;/code&gt;&lt;/a&gt; so the next time it will mount that dataset correctly.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How I did a turbo mode system in GCP for cheap</title>
      <dc:creator>Lucas Eduardo</dc:creator>
      <pubDate>Wed, 06 Jul 2022 16:07:24 +0000</pubDate>
      <link>https://forem.com/lucasew/how-i-did-a-turbo-mode-system-in-gcp-for-cheap-4and</link>
      <guid>https://forem.com/lucasew/how-i-did-a-turbo-mode-system-in-gcp-for-cheap-4and</guid>
      <description>&lt;p&gt;Cloud instances are very useful when you need compute power but don't want to buy machines and deal with the maintenance burden of maintaining physical machines, or just don't need them long enough to make it worth buying hardware. The idea is basically rent a remote machine for the time you need them and pay exactly for what you used.&lt;/p&gt;

&lt;p&gt;This can be a pretty simple concept but can be very hard to implement. There are literally hundreds, or even thousands, of combinations and use cases that cloud providers support. Our focus on this article is the most basic use case ever: you rent a VM and pay for how much time and space it uses.&lt;/p&gt;

&lt;p&gt;This article is focused on the Google Cloud Platform quirks, and my specific project is a NixOS VPS to use GPUs in the cloud for cheap.&lt;/p&gt;

&lt;h1&gt;
  
  
  The strategy
&lt;/h1&gt;

&lt;p&gt;Now (6/7/2022) there are some resources that are free forever, like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;30GB of total balanced storage&lt;/li&gt;
&lt;li&gt;A e2-micro (0.5VCPU burstable to 2VCPU) instance for the whole month&lt;/li&gt;
&lt;li&gt;1GB of egress network in almost all continents&lt;/li&gt;
&lt;li&gt;Free egress network for Google services&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The idea is to use Terraform to migrate one instance to TURBO MODE to do the beefy stuff, and use the same system in an e2-micro for configuration, preparation, uploads, maintenance and so on. &lt;/p&gt;

&lt;p&gt;The turbo instance can be a spot instance for extra cheap. Spot instances are cheaper because these can be interrupted at any time.&lt;/p&gt;

&lt;p&gt;My OS of choice is NixOS because of the code based construction and, in my opinion, is more convenient to setup and replicate. I can replicate the same setup as many times as I want doing specific customizations for one specific deployment if I want.&lt;/p&gt;

&lt;h1&gt;
  
  
  The code
&lt;/h1&gt;

&lt;p&gt;The code I used in this experiment is stored in my &lt;a href="https://github.com/lucasew/nixcfg"&gt;dotfiles repo&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The Terraform file I am using for this experiment is stored in &lt;code&gt;infra/gcp.tf&lt;/code&gt;. The Terraform state is stored in Terraform cloud.&lt;/p&gt;

&lt;p&gt;The NixOS machine that I run in GCP is defined in &lt;code&gt;nodes/vps&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;There are some CUDA specific stuff in the file &lt;code&gt;nvidia.nix&lt;/code&gt;. Tesla K80 doesn't support the latest driver so I had to use legacy 470. Tested with some Blender renders and it's working fine with CUDA and works correctly for what I need.&lt;/p&gt;

&lt;h1&gt;
  
  
  How to deploy
&lt;/h1&gt;

&lt;p&gt;To deploy the instance in normal mode I run the following command in the infra folder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;terraform apply
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And if I want to migrate it to the turbo instance I run the following command in the infra folder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;terraform apply &lt;span class="nt"&gt;-var&lt;/span&gt; &lt;span class="s1"&gt;'modo_turbo=true'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Final thoughs
&lt;/h1&gt;

&lt;p&gt;It was a pretty challenging project, and I though I would spend much more money in this. I did this tiering stuff in two days. I took a lot of time to figure out how to configure CUDA then I realized that &lt;code&gt;hardware.opengl.enable&lt;/code&gt; must be enabled to allow software to find the CUDA driver 🤡.&lt;/p&gt;

&lt;h1&gt;
  
  
  Future work
&lt;/h1&gt;

&lt;p&gt;I need to find a way to automatically turn off the turboed machine when the job is over, automatically. I might do some wizardry with systemd units. I will not probably update this post. The code that will be changed for that project is in the VPS folder or some common module that I could use in any of my machines.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>OpenCL on Blender with Intel Integrated GPUs</title>
      <dc:creator>Lucas Eduardo</dc:creator>
      <pubDate>Fri, 01 Apr 2022 19:13:27 +0000</pubDate>
      <link>https://forem.com/lucasew/opencl-on-blender-with-intel-gpus-oep</link>
      <guid>https://forem.com/lucasew/opencl-on-blender-with-intel-gpus-oep</guid>
      <description>&lt;p&gt;So far &lt;strong&gt;only AMD&lt;/strong&gt;'s OpenCL is officially supported but if you like to take some risks you can force enable OpenCL on Intel setting two environment variables:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;CYCLES_OPENCL_SPLIT_KERNEL_TEST=1&lt;/strong&gt;: That's the one referenced in any post about it&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CYCLES_OPENCL_TEST=all&lt;/strong&gt;: that variable is not so mentioned &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A detail that you might forget is that you need to install the OpenCL drivers for your GPU before doing this. My 7th gen i5 still uses the legacy driver. The still maintained driver is for 8th gen and above. The driver link is broken but Wayback Machine covers this case fortunately.&lt;/p&gt;

&lt;p&gt;Here is a full command for quick testing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;CYCLES_OPENCL_TEST&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;all &lt;span class="nv"&gt;CYCLES_OPENCL_SPLIT_KERNEL_TEST&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1 blender &lt;span class="nt"&gt;--python-expr&lt;/span&gt; &lt;span class="s2"&gt;"import bpy; [[print(d.type, d) for d in ds] for ds in bpy.context.preferences.addons['cycles'].preferences.get_devices()]"&lt;/span&gt; &lt;span class="nt"&gt;--verbose&lt;/span&gt; 69 &lt;span class="nt"&gt;-E&lt;/span&gt; CYCLES &lt;span class="nt"&gt;-b&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And that's the output that appears on my machine:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Blender 2.93.5
Read prefs: /home/lucasew/.config/blender/2.93/config/userpref.blend
[ALSOFT] (EE) Failed to set real-time priority for thread: Operation not permitted (1)
[ALSOFT] (EE) Failed to set real-time priority for thread: Operation not permitted (1)
I0401 16:07:26.994379 438579 blender_python.cpp:195] Debug flags initialized to:
CPU flags:
  AVX2       : True
  AVX        : True
  SSE4.1     : True
  SSE3       : True
  SSE2       : True
  BVH layout : EMBREE
  Split      : False
CUDA flags:
  Adaptive Compile : False
OptiX flags:
  CUDA streams : 1
OpenCL flags:
  Device type    : ALL
  Debug          : False
  Memory limit   : 0
I0401 16:07:28.091580 438579 device_cuda.cpp:56] CUEW initialization failed: Error opening the library
I0401 16:07:28.091853 438579 device_opencl.cpp:48] CLEW initialization succeeded.
I0401 16:07:28.093667 438579 opencl_util.cpp:957] Enumerating devices for platform Intel(R) OpenCL.
I0401 16:07:28.093719 438579 opencl_util.cpp:777] OpenCL driver version 1.2
I0401 16:07:28.093741 438579 opencl_util.cpp:993] Using more readable device name: Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz (OpenCL)
I0401 16:07:28.093761 438579 opencl_util.cpp:995] Adding new device Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz (OpenCL).
CPU &amp;lt;bpy_struct, CyclesDeviceSettings("Intel Core i5-7200U CPU @ 2.50GHz") at 0x7f812be0b608&amp;gt;
OPENCL &amp;lt;bpy_struct, CyclesDeviceSettings("Intel Core i5-7200U CPU @ 2.50GHz (OpenCL)") at 0x7f812be0b688&amp;gt;
CPU &amp;lt;bpy_struct, CyclesDeviceSettings("Intel Core i5-7200U CPU @ 2.50GHz") at 0x7f812be0b608&amp;gt;

Blender quit

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With this a OpenCL GPU will appear on preferences.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zKSq9PYc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i0e74dkp0oeq00nbjk6g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zKSq9PYc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i0e74dkp0oeq00nbjk6g.png" alt="OpenCL device appearing on blender settings" width="880" height="482"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But beware, in my case when I started rendering the CPU only got 100% but without slowdown the computer and Blender just stop reacting to any input so working is a too strong word.&lt;/p&gt;

&lt;p&gt;Tested with Blender 2.93. Both nixpkgs and blender-bin 2.93 definitions works basically the same way.&lt;/p&gt;

</description>
      <category>blender</category>
      <category>opencl</category>
      <category>intel</category>
    </item>
    <item>
      <title>So videos don't have Ctrl+F...</title>
      <dc:creator>Lucas Eduardo</dc:creator>
      <pubDate>Sun, 13 Sep 2020 12:56:05 +0000</pubDate>
      <link>https://forem.com/lucasew/so-videos-don-t-have-ctrl-f-27l3</link>
      <guid>https://forem.com/lucasew/so-videos-don-t-have-ctrl-f-27l3</guid>
      <description>&lt;p&gt;&lt;a href="https://youtube-dl.org/"&gt;Youtube-dl&lt;/a&gt; is an awesome download tool for videos and audios in a huge amount of sites but there are some features that people don't usually use. One of them is to download video subtitles that sometimes is available.&lt;/p&gt;

&lt;p&gt;Youtube-dl is a CLI program, it can be a bit difficult for begginners but it will be worth learning. I promise.&lt;/p&gt;

&lt;p&gt;People usually just use youtube-dl with a link, maybe referencing a list of links using the &lt;code&gt;-a&lt;/code&gt; flag.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;youtube-dl &lt;span class="nv"&gt;$link&lt;/span&gt;
youtube-dl &lt;span class="nt"&gt;-a&lt;/span&gt; &lt;span class="nv"&gt;$file&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you run &lt;code&gt;youtube-dl --help&lt;/code&gt; there will be a lot of options and I will show some of them related to subtitles;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;--list-subs&lt;/code&gt;: Shows the list of embedded subtitles that the video have. Usually not that useful, at least not in this case xD;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;--write-subs&lt;/code&gt;: Downloads the subtitles that are embedded in the video;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;--sub-lang&lt;/code&gt;: Specifies a language to the downloaded subtitles, the default is en. In brazil the language is pt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;--sub-format&lt;/code&gt;: Specifies a file format of the downloaded subtitles. The default is &lt;code&gt;VTT&lt;/code&gt; and is the fallback if the specified formats aren't available to download;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;--write-auto-sub&lt;/code&gt;: This is the flag I was talking about xD. This flag downloads the subtitle automatically generated in youtube, the video transcript. lang and format flags are hints about what subtitle will be downloaded;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After downloading the subtitle, the program will also download the video, if you just want the subtitle you can use the flag &lt;code&gt;--skip-download&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Batching works too, so if you want to download a full playlist or a file with all the URLs using &lt;code&gt;-a&lt;/code&gt; you can and it will work.&lt;/p&gt;

&lt;p&gt;When you download a subtitle you download not a &lt;code&gt;TXT&lt;/code&gt; file full of words but a &lt;code&gt;VTT&lt;/code&gt; file, that if you want just the text you can delete the unwanted parts. In every text line there is a fixed lines of other data that you can delete using someting like a &lt;code&gt;vim&lt;/code&gt; macro, &lt;code&gt;sed&lt;/code&gt; or other text manipulation tool you like.&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>todayilearned</category>
    </item>
  </channel>
</rss>
