Skip to content
This repository was archived by the owner on Sep 8, 2024. It is now read-only.

Check for AVX instruction set during install for Precise compatibility #2269

Closed
wants to merge 7 commits into from

Conversation

mathmauney
Copy link
Contributor

Description

(Description of what the PR does, such as fixes # {issue number})
Check for AVX instruction set during install and warns the user that the Precise Engine will not be supported.

How to test

(Description of how to validate or test this PR)
Run installer on a machine that does not support AVX

Contributor license agreement signed?

CLA [ ] (Whether you have signed a CLA - Contributor Licensing Agreement

@pep8speaks
Copy link

pep8speaks commented Aug 23, 2019

Hello @mathmauney! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2019-08-29 15:40:55 UTC

@devs-mycroft
Copy link
Collaborator

Hello, @mathmauney, thank you for helping with the Mycroft project! We welcome everyone
into the community and greatly appreciate your help as we work to build an AI
for Everyone.

To protect yourself, the project, and users of Mycroft technologies we require
a Contributor Licensing Agreement (CLA) before accepting any code
contribution. This agreement makes it crystal clear that along with your
code you are offering a license to use it within the confines of this project.
You retain ownership of the code, this is just a license.

Please visit https://mycroft.ai/cla to initiate this one-time signing. Thank
you!

@devs-mycroft devs-mycroft added the CLA: Needed Need signed CLA from https://mycroft.ai/cla label Aug 23, 2019
@mathmauney
Copy link
Contributor Author

Currently waiting on my CLA form.

Sorry about the line too long error, I disabled those in my PEP

dev_setup.sh Outdated
@@ -137,6 +137,22 @@ This script is designed to make working with Mycroft easy. During this
first run of dev_setup we will ask you a few questions to help setup
your environment.'
sleep 0.5
if ! grep -q avx /proc/cpuinfo; then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this condition apply to the ARM platform as well? Since we have a precise build for that platform it might need to be excluded.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't know about the ARM exception. Looks like that can be easily checked with $(uname -m) == 'arm'* so I've added that to the logic

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not easy to know :)

That looks like a good solution, great work with that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, we had some chat about this on the Forums. According to @domcross the ARM equivalent is called SIMD (Single Instruction, Multiple Data) and is available since ARMv7 (which includes the Cortex A53 used by the RaspberryPi and the Cortex A7 from the OrangePi).
Is it worth checking for SIMD on ARM?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The arm equivalents seem to have a bunch of different names. on the Pi it's neon and on the H64 it's called asimd so it might not be trivial to do a correct general check.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good to know, ignore me then :)
I think there's much less presumption that it will work on random ARM hardware anyway.

@@ -326,6 +332,10 @@ def initialize():
hotword, module
))
instance = None
except PreciseUnavailable:
LOG.warning('Settings prevent Precise Engine use,
falling back to default.')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm this multiline string doesn't seem to be valid. I suggest using

        LOG.warning('Settings prevent Precise Engine use, '
                    'falling back to default.')

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, thought that was what I changed it to already. Should be fixed now.

Fix long line string
@mathmauney
Copy link
Contributor Author

CLA has been submitted

@devs-mycroft devs-mycroft added CLA: Yes Contributor License Agreement exists (see https://github.com/MycroftAI/contributors) and removed CLA: Needed Need signed CLA from https://mycroft.ai/cla labels Aug 26, 2019
dev_setup.sh Outdated
Y)es, I want to use the PocketSphinx engine or my own.
N)o, stop the installation."
if get_YN ; then
sed -i "s/\"use_precise\": true/\"use_precise\": false/" config/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this sed line correct?
I get
sed: can't read config/: No such file or directory

Not sure which config you intend to edit here but you should probably make the adjustments in the ~/.mycroft/mycroft.conf config

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah that's where I had a test copy of a .conf.

It looks like there isn't any automatically generated one so we would have to deal with that.

Would the system level one be a better spot since you either will or will not have AVX for the entire system rather than at a user level?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed might be better

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok that should be done, it worked when I tested on a new system if I forced it to take that path. I don't have any machines that aren't ARM or AVX-compatible to really test on though.

Copy link
Contributor

@krisgesling krisgesling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there, sorry this dropped off my radar for a bit. It's a great addition though.

What do you think about the following?

if [[ ! -e /etc/mycroft/ ]]; then
$SUDO mkdir /etc/mycroft
fi
$SUDO cp $TOP/mycroft/configuration/mycroft.conf /etc/mycroft/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to copy the default config across?
The default config will be used in its current location, and a config at /etc/mycroft/mycroft.conf would override it, (details here in our docs).

So wondering if we:

  1. create the directory
  2. create an empty json file if it doesn't exist
  3. use jq to add/update the specific value
jq -c '. + { "use_precise": true }' mycroft.conf > tmp.$$.conf && mv tmp.$$.conf mycroft.conf

Comment on lines +151 to +153
if [[ ! -e /etc/mycroft/ ]]; then
$SUDO mkdir /etc/mycroft
fi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OPTIONAL
For creating the directory, personally I use mkdir -p instead of using a conditional. So these 3 lines could be simplified to:

$SUDO mkdir -p /etc/mycroft

@krisgesling krisgesling added Status: Change requested and removed Status: To be reviewed Concept accepted and PR has sufficient information for full review labels Nov 23, 2020
@krisgesling krisgesling changed the title Feature/issue 2232 Check for AVX instruction set during install for Precise compatibility Apr 30, 2021
@krisgesling
Copy link
Contributor

Closing in favor of #2910

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CLA: Yes Contributor License Agreement exists (see https://github.com/MycroftAI/contributors) Status: Change requested Type: Bug - complex
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants