// you’re reading...

Blog

Compiling Ultra fast Blender 3D on Ubuntu

Rajiv

Rajiv

Well, here are the necessary steps to compile an ultra fast Blender-3D binary on Ubuntu 8.10.

To install the build dependencies:
Type in the terminal”

sudo apt-get build-dep blender

followed by

sudo apt-get install subversion
then at root type:

svn checkout https://svn.blender.org/svnroot/bf-blender/trunk/blender

cd into blender
Add these lines in text editor and save it at blender root as “user-config.py” before you compile: (same place where SConstruct resides)

BFWITH_BF_INTERNATIONAL = ‘true’
WITH_BF_VERSE = ‘true’
WITH_BF_YAFRAY = ‘true’
WITH_BF_GAMEENGINE=’true’
WITH_BF_BULLET = ‘true’
WITH_BF_PLAYER = ‘true’
WITH_BF_ODE = ‘true’
WITH_BF_JPEG = ‘true’
WITH_BF_PNG = ‘true’
WITH_BF_OPENEXR = ‘true’
WITH_BF_FTGL = ‘true’
WITH_BF_FMOD = ‘true’
WITH_BF_FFMPEG = ‘true’
WITH_BF_QUICKTIME = ‘false’
WITH_BF_OPENAL = ‘true’
WITH_BF_SDL = ‘true’
WITH_BF_ICONV = ‘false’
WITH_BF_STATICOPENGL = ‘false’
BF_PYTHON_VERSION = ’2.5′
BF_DEBUG = ‘false’
BF_TWEAK_MODE = ‘false’

CCFLAGS = ['-pipe', '-fPIC', '-march=nocona', '-ftracer', '-fomit-frame-pointer', '-ffast-math', '-m3dnow', '-msse', '-msse2', '-msse3', '-msse4', '-mmmx', '-funroll-loops','-frerun-cse-after-loop', '-frerun-loop-opt', '-fforce-addr', '-funsigned-char', '-fno-strict-aliasing']
CPPFLAGS = ['-DXP_UNIX']
CXXFLAGS = ['-pipe', '-fPIC', '-march=nocona', '-ftracer', '-fomit-frame-pointer', '-ffast-math', '-m3dnow', '-msse', '-msse2', '-msse3', '-msse4', '-mmmx', '-funroll-loops', '-frerun-cse-after-loop', '-frerun-loop-opt', '-fforce-addr', '-funsigned-char', '-fno-strict-aliasing']

REL_CFLAGS = ['-O3', '-fomit-frame-pointer', '-funroll-loops']
REL_CCFLAGS = ['-O3', '-fomit-frame-pointer', '-funroll-loops']

Next: Change these lines in the cmakelist file:

# Set default config options
OPTION(WITH_PLAYER “Build Player” ON)
OPTION(WITH_GAMEENGINE “Enable Game Engine” ON)
OPTION(WITH_BULLET “Enable Bullet (Physics Engine)” ON)
OPTION(WITH_INTERNATIONAL “Enable I18N (International fonts and text)” ON)
OPTION(WITH_VERSE “Enable Verse (http://verse.blender.org)” ON)
OPTION(WITH_ELBEEM “Enable Elbeem (Fluid Simulation)” ON)
OPTION(WITH_QUICKTIME “Enable Quicktime Support” OFF)
OPTION(WITH_OPENEXR “Enable OpenEXR Support (http://www.openexr.com)” ON)
OPTION(WITH_FFMPEG “Enable FFMPeg Support (http://ffmpeg.mplayerhq.hu/)” ON)
OPTION(WITH_OPENAL “Enable OpenAL Support (http://www.openal.org)” ON)
OPTION(YESIAMSTUPID “Enable execution on 64-bit platforms” ON)
OPTION(WITH_OPENMP “Enable OpenMP (has to be supported by the compiler)” ON)

Now you are ready to go
Type: scons
scons install

and you are done.
I am sure you will see 30 to 40 percent speed increase in your renders.

Discussion

21 comments for “Compiling Ultra fast Blender 3D on Ubuntu”

  1. Hello Rajiv, compiling without errors, but blender crash directly after i start it.
    Error in console=
    “ungueltiger Maschinenbefehl” in english
    “invalid computer instruction”
    opensuse 11/64
    intel Q6006
    Where i start deleting flags in user-config.py.
    3dnow and frerun-cse-after-loop is ereased, but the same error.
    Greets mib

    ps. is it possible to expand this textfield or reduce textsize.
    It is very hard to write in. :-)

    Posted by mib2berlin | September 19, 2008, 11:14 pm
  2. Hi mib2berlin

    Are you using opensuse?

    I wrote these instructions for Ubuntu 8.10.

    as you can see, it states in the flag statement “nocona” if you have another cpu, you need to replace it with that, for example if your cpu is Intel Core 2 quad Q6600, then you need to replace “nocona” with “athlon64″ in “CCFLAGS = ['-pipe', '-fPIC', '-march=nocona', '-ftracer', '-fomit-frame-pointer', '-ffast-math', '-m3dnow', '-msse', '-msse2', '-msse3', '-msse4', '-mmmx', '-funroll-loops','-frerun-cse-after-loop', '-frerun-loop-opt', '-fforce-addr', '-funsigned-char', '-fno-strict-aliasing']
    CPPFLAGS = ['-DXP_UNIX']
    CXXFLAGS = ['-pipe', '-fPIC', '-march=nocona', '-ftracer', '-fomit-frame-pointer', '-ffast-math', '-m3dnow', '-msse', '-msse2', '-msse3', '-msse4', '-mmmx', '-funroll-loops', '-frerun-cse-after-loop', '-frerun-loop-opt', '-fforce-addr', '-funsigned-char', '-fno-strict-aliasing']”

    I hope that should solve your problem

    Posted by Rajiv | September 20, 2008, 4:35 pm
  3. Thank you for reply, change to athlon64 dosend matter, i change to CCFLAGS. CPPFLAGS do not work.
    But i am a newbie with compiling, and i try to build a fast blender works also with YoFrankie. http://www.yofrankie.org/
    Regards,
    Mib

    Posted by mib2berlin | September 21, 2008, 3:38 pm
  4. Rajiv: OK, but you should also warn people:

    DO NOT USE SUCH BLENDER BUILD FOR A PRODUCTION!!!

    Such aggressive optimizations (-O3 with -ffast-math?!) lead into serious computing errors!

    Posted by Igor | October 5, 2008, 2:37 pm
  5. Hi Igor. Thanks for the warning, but there is nothing to worry with the present builds.
    I personally haven’t seen any or encountered any problems and I am using it for Film and Video production.
    The only drawback is that the size of the executables, once in ram it takes up almost twice the space compared to an un-optimized blender (that is a well 40mb extra).

    I have used the optimized blender to run complex liquid simulations with SSS and Raytrace with AA and was pleased with the results.
    It rendered almost 35 percent fast with no visible artifact, Infact I compared the result with the non-optimized official blender build and found no perceptible difference.

    I did run into problems with 2,44 build, but with 2.6 and 2.8 builds, a 40 percent speed increase is worth the risk.
    So if you can afford a slight increase in the size of the executables, I would recommend any one to go for it -ram is cheap these days.

    But sure I should have added (try at your own risk) and yes these optimizations have no effect on external renderers… so if you encounter render glitches as I did on 2.44 build keep the official build handy.

    Thanks for the warning

    Rajiv

    Posted by Rajiv | October 6, 2008, 5:12 pm
  6. Ubuntu 8.10 here.  After running the first line “sudo apt-get build-dep blender” I get:

    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    E: Unable to find a source package for blender

    any ideas?

    Posted by Ben | November 15, 2008, 1:04 am
  7. HI Ben
    try now and let me know if everything works.

    Posted by Rajiv | November 27, 2008, 9:51 am
  8. I’m getting the exact same thing.  Is there something else I need to do before running the “sudo apt-get build-dep blender” line?

    Posted by Ben | November 27, 2008, 1:41 pm
  9. Hi Ben Strange! Everything works fine here, I did a fresh (temp) install and everything went fine.

    check that you have all the default repository enables including Medibuntu

    run$ sudo apt-get install ubuntustudio-graphics

    -and let me know what it says?

    Posted by Rajiv | November 28, 2008, 4:02 am
  10. I did that command, and it installed almost 200MB of additional things, and then required a reboot.  After the reboot, I re-ran the “sudo apt-get build-dep blender” command, and still got the same “Unable to find a source package for blender” as before.

    Also, when I try to run Blender from console it says:
    guessing ‘blender-bin’ == ‘/usr/bin/blender-bin’
    Compiled with Python version 2.5.2.
    Checking for installed Python… got it!
    Segmentation fault

    and my screen flashes quickly as if it was trying to open, and then nothing else happens.  Checking my processes after this, there is nothing named “blender” running in the background.

    (Btw, running a downloaded copy of Blender seems to run OK… except when I try to choose “Hotkey and MouseAction reference” from the Help menu, it tells me “Python Script Error: Check console”. But I can’t check the console because I can’t figure out how to run the downloaded copy *from* the console, and Blender here in Ubuntu doesn’t give me a separate console window when you run it like it does in Windows…)

    Posted by Ben | November 28, 2008, 5:11 pm
  11. Ben, There are several reasons why Segmentation fault occurs, for example “when critical shared libs, config file or /dev/ entry missing. or drivers esp onboard graphic related ones can also create problem. I have also seen this with AMD-Ati GPU’s.”
    The “Python Script Error” might be related to missing shared libs, config file or /dev/ entry’s

    Kindly note that you can run blender in console mode by typing
    ./blender
    or
    ./Blender/blender
    or cd[ing] into the dir and simply running blender from there by typing blender -w

    also note that the 810 release is still buggy. check that you have all the updates by typing$ sudo apt-get update and sudo apt-get upgrade

    you may want to run$
    sudo apt-get autoclean
    followed by
    sudo apt-get update
    sudo apt-get dist-upgrade

    If the downloaded copy of Blender runs OK, then I would recommend you to use it while Ubuntu irons out the bugs.
    Usually the long term release (804) are rock solid followed by experimental release (810) and a Userfriendly release (904)

    Nevertheless, If you decide to reinstall 810 I suggest you do a memory check as well as disk (CD) check when it gives you the option at boot.
    Usually its faster to resolve the problem by having a quick clean re-install.

    Before you do a re-install you can try creating a new User and logging into him
    This will create a new home folder and re-fresh the directory list.

    Regards
    -Rajiv

    Posted by Rajiv | November 28, 2008, 6:37 pm
  12. Thanks for all the info.

    What would I need to do to make a ‘ultra fast Blender’ for Ubuntu 8.04 instead of 8.10?

    Posted by Ben | November 29, 2008, 12:56 am
  13. Hi Ben, you just need to download and install a fresh copy of Ubuntu liveCD from their site.
    Also I recommend using UbuntuStudio rather than Ubuntu.
    you can download it from here: http://cdimage.ubuntu.com/ubuntustudio/releases/8.10/release/
    or
    http://cdimage.ubuntu.com/ubuntustudio/releases/8.04.1/release/

    hope that helps :)

    Posted by Rajiv | November 29, 2008, 11:51 pm
  14. Thanks… But I know where to get it and how to install it.  :) I’ve gone back and forth between Ubuntu and UbuntuStudio in the past.

    But anyways, I’m going to put 8.04 on another partition, and wanted to know what steps I’d have to take to “compile an ultra fast Blender-3D binary” … on 8.04 instead of 8.10.  Is it the same steps as above, or do I need to do something different?

    Posted by Ben | December 1, 2008, 12:25 am
  15. Yes Ben, the steps are the same :)

    Posted by Rajiv | December 1, 2008, 12:46 am
  16. Hello Ravij, can i do this on Linux mint? I’m new to compiling so if there should be any changes to the process please explain it a bit.

    thank you

    Posted by Freyd | December 10, 2008, 5:29 am
  17. Certainly Freyd (atleast as far as the last one which If I am not wrong is ‘Elyssa’)
    Please see that that the new one (RC1) has problem with the new python (scons) though unconfirmed! cant say for sure.

    Posted by Rajiv | December 10, 2008, 8:04 am
  18. Hello Rajii how do I optamixe system specific blender builds for xubuntu

    I also want a stable a fast and an ultra fast blender.
    thankyou
    Mike chang

    Posted by Dark Night | January 4, 2009, 11:25 am
  19. Hi Mike

    You have to do 3 things I suppose

    For Stable use these:

    CCFLAGS = ['-pipe','-fPIC','-march=native','-mtune=native','-msse','-msse2','-msse3','-mssse3','-mmmx','-mfpmath=sse','-funsigned-char','-fno-strict-aliasing']
    CXXFLAGS = ['-pipe','-fPIC','-march=native','-mtune=native','-msse','-msse2','-msse3','-mssse3','-mmmx','-mfpmath=sse','-funsigned-char','-fno-strict-aliasing']
    REL_CFLAGS = ['-O2','-fomit-frame-pointer','-funroll-loops']
    REL_CCFLAGS = ['-O2','-fomit-frame-pointer','-funroll-loops']

    For Fast use these:

    CCFLAGS = ['-pipe','-fPIC','-march=native','-mtune=native','-msse','-msse2','-msse3','-mssse3','-mmmx','-mfpmath=sse','-funsigned-char','-fno-strict-aliasing']
    CXXFLAGS = ['-pipe','-fPIC','-march=native','-mtune=native','-msse','-msse2','-msse3','-mssse3','-mmmx','-mfpmath=sse','-funsigned-char','-fno-strict-aliasing']
    REL_CFLAGS = ['-O3','-fomit-frame-pointer','-funroll-loops']
    REL_CCFLAGS = ['-O3','-fomit-frame-pointer','-funroll-loops']

    for Ultra Fast use these:

    CCFLAGS = ['-pipe','-fPIC','-march=native','-mtune=native','-ftracer','-fomit-frame-pointer','-ffast-math','-m3dnow','-msse','-msse2','-msse3','-mssse3','-mmmx','-funroll-loops','-frerun-cse-after-loop','-frerun-loop-opt','-fforce-addr','-funsigned-char','-fno-strict-aliasing']
    CPPFLAGS = ['-DXP_UNIX']
    CXXFLAGS = ['-pipe','-fPIC','-march=native','-mtune=native','-ftracer','-fomit-frame-pointer','-ffast-math','-m3dnow','-msse','-msse2','-msse3','-mssse3','-mmmx','-funroll-loops','-frerun-cse-after-loop','-frerun-loop-opt','-fforce-addr','-funsigned-char','-fno-strict-aliasing']

    REL_CFLAGS = ['-O3','-fomit-frame-pointer','-funroll-loops']
    REL_CCFLAGS = ['-O3','-fomit-frame-pointer','-funroll-loops']

    If you are using a 64 buildadd these below

    BF_OPENAL_LIB = ‘openal alut’
    #BF_OPENAL_LIBPATH = ‘${BF_OPENAL}/lib64′
    WITH_BF_OPENMP = ‘true’
    WITH_BF_OGG = ‘true’
    WITH_BF_INTERNATIONAL = ‘true’
    WITH_BF_ELBEEM = ‘true’
    WITH_BF_VERSE = ‘true’
    WITH_BF_YAFRAY = ‘true’
    WITH_BF_GAMEENGINE=’true’
    WITH_BF_BULLET = ‘true’
    WITH_BF_PLAYER = ‘true’
    WITH_BF_ODE = ‘true’
    WITH_BF_JPEG = ‘true’
    WITH_BF_PNG = ‘true’
    WITH_BF_OPENEXR = ‘true’
    WITH_BF_FTGL = ‘true’
    WITH_BF_FMOD = ‘true’
    WITH_BF_FFMPEG = ‘true’
    WITH_BF_QUICKTIME = ‘false’
    WITH_BF_OPENAL = ‘true’
    WITH_BF_SDL = ‘true’
    WITH_BF_ICONV = ‘false’
    WITH_BF_STATICOPENGL = ‘false’
    BF_PYTHON_VERSION = ’2.5′
    BF_DEBUG = ‘false’
    BF_TWEAK_MODE = ‘false’

    let me know how it went
    also note as you asked for specific system centric builds, these builds may or may not work on systems other then those on which they are built.
    also try experimenting with the various settings, they are explained in detail in the GCC manual.

    Posted by Rajiv | January 4, 2009, 1:38 pm
  20. For 2.5 ubuntu 910 do the following

    install deps:

    sudo apt-get install subversion scons g++ libx11-dev libgl1-mesa-dev libxi-dev zlib1g-dev libpng12-dev libglu1-mesa-dev build-essential libjpeg-dev libjpeg62-dev libfreetype6-dev libtiff4-dev libopenexr-dev libsdl1.2-dev libsdl-dev libopenal-dev python-dev python3.1-dev libfftw3-dev libsamplerate0-dev libjack-dev libavformat-dev libxvidcore4-dev libogg-dev libfaac-dev libfaad-dev libx264-dev libmp3lame-dev libvorbis-dev libtheora-dev libswscale-dev libavdevice-dev libalut-dev gettext yasm cmake openexr

    and then:

    svn checkout https://svn.blender.org/svnroot/bf-blender/trunk/blender

    finally create these user-config.py:

    BF_NUMJOBS = ’4′
    WITH_BF_OPENMP = ‘true’
    WITH_BF_SNDFILE = ‘true’
    WITH_BF_OPENAL = ‘true’
    WITH_BF_JACK = ‘true’
    WITH_BF_SDL = ‘true’
    WITH_BF_OPENEXR = ‘true’
    WITH_BF_DDS = ‘true’
    WITH_BF_JPEG = ‘true’
    WITH_BF_PNG = ‘true’
    WITH_BF_ZLIB = ‘true’
    WITH_BF_BULLET = ‘true’
    WITH_BF_OGG = ‘true’
    WITH_BF_FFTW3 = ‘true’
    WITH_BF_OPENJPEG = ‘true’
    WITH_BF_REDCODE = ‘true’
    WITH_BF_OPENGL = ‘true’
    BF_OPENGL=’/usr/lib64′
    BF_OPENGL_LIBPATH = ‘/usr/lib64′
    BF_OPENGL_LIBPATH = ‘${BF_OPENGL}/usr/lib64′

    Posted by Rajiv | November 21, 2009, 8:03 am
  21. If I may add to a great thread, there is great info from the Gentoo community about cflags:
    http://en.gentoo-wiki.com/wiki/Safe_Cflags
    Its worth noting, that sse4 is valid for opteron/k10 and Intel i7, and when used sse3 is ignored as all sse3 instructions are part of sse4 anyhow. Its also important to know what version of gcc you have installed.

    Posted by Ric | February 8, 2010, 5:16 pm

Post a comment